Skip to content

Commit

Permalink
Listeners Lexical: 3 updates to spelling and grammar - Update listene…
Browse files Browse the repository at this point in the history
…rs.md (facebook#7100)
  • Loading branch information
DocAdam authored Jan 28, 2025
1 parent 9fcc494 commit 8e2ede2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/lexical-website/docs/concepts/listeners.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Listeners

Listeners are a mechanism that lets the Editor instance inform the user when a certain operation has occured. All listeners follow a reactive pattern where you can do an operation upon something happening in the future. All listeners also return a function that easily allows for the
Listeners are a mechanism that lets the Editor instance inform the user when a certain operation has occurred. All listeners follow a reactive pattern where you can do an operation upon something happening in the future. All listeners also return a function that easily allows for the
listener to be unregistered. Below are the different listeners that Lexical supports today:

## `registerUpdateListener`
Expand Down Expand Up @@ -31,7 +31,7 @@ The update listener callbacks receives a single argument containing the follow p
- `tags` a Set of all tags that were passed to the update

One thing to be aware of is "waterfall" updates. This is where you might schedule an update inside an update
listener, as show below:
listener, as shown below:

```js
editor.registerUpdateListener(({editorState}) => {
Expand All @@ -48,7 +48,7 @@ editor.registerUpdateListener(({editorState}) => {
```

The problem with this pattern is that it means we end up doing two DOM updates, when we likely could have
done it in a single DOM update. This can have an impact on performance, which is important in text editor.
done it in a single DOM update. This can have an impact on performance, which is important in a text editor.
To avoid this, we recommend looking into [Node Transforms](https://lexical.dev/docs/concepts/transforms), which allow you to listen to node changes and
transform them as part of the same given update, meaning no waterfalls!

Expand Down

0 comments on commit 8e2ede2

Please sign in to comment.