From d15cfe460d951782fd13d20edee822c716c8df27 Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Mon, 18 Dec 2023 16:07:40 -0300 Subject: [PATCH] move note to bottom as per #149 --- docs/state/schema-callbacks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/state/schema-callbacks.md b/docs/state/schema-callbacks.md index 07a6486a..71d6c354 100644 --- a/docs/state/schema-callbacks.md +++ b/docs/state/schema-callbacks.md @@ -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 @@ -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)`