Skip to content

Commit

Permalink
move note to bottom as per #149
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Dec 18, 2023
1 parent 5c326b9 commit d15cfe4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/state/schema-callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ Register the `onAdd` callback is called whenever a new instance is added to a co

By default, the callback is called immediately for existing items in the collection.

!!! Note "Avoiding doubled-up callbacks"
You may notice that `onAdd` is called multiple times when an entry is inserted. This is because the "add" callback is called immediately by default for existing items in the collection. When the collection is nested within another schema instance, this can cause doubling. To fix this, set the second argument of `onAdd` to false (e.g. `.onAdd(callback, false)`). See [#147](https://github.com/colyseus/schema/issues/147#issuecomment-1538684941).

=== "JavaScript"

``` typescript
Expand Down Expand Up @@ -191,6 +188,9 @@ By default, the callback is called immediately for existing items in the collect
end)
```

!!! Note "Avoiding doubled-up callbacks"
You may notice that `onAdd` is called multiple times when an entry is inserted. This is because the "add" callback is called immediately by default for existing items in the collection. When the collection is nested within another schema instance, this can cause doubling. To fix this, set the second argument of `onAdd` to false (e.g. `.onAdd(callback, false)`). See [#147](https://github.com/colyseus/schema/issues/147#issuecomment-1538684941).

---

#### `onRemove (item, key)`
Expand Down

0 comments on commit d15cfe4

Please sign in to comment.