Closed mobyjames closed 5 years ago
Oddly, if I convert the field to ArraySchema<string>
the onAdd method fires, but the issue with onRemove remains. It only fires for the first removed item.
The OnRemove()
issue was a silly mistake during the remove loop: https://github.com/colyseus/colyseus-unity3d/commit/f8ec63558470fdf9a7a90532daa881561b557d82
Apparently the OnAdd()
wasn't triggering because of the check for new keys in the Dictionary (https://github.com/colyseus/colyseus-unity3d/commit/c7f9cbcdedc0aef93e8c36d3026aeca8862a7276). The currentValue[newIndex]
returns default(int)
instead of null
. So I've changed this check to use .ContainsKey(newIndex)
instead.
I'm afraid MapSchema also has the OnAdd()
problem with numbers, I haven't tested with it yet!
Please see latest in this repro for example: https://github.com/mobyjames/colyseus-unity3d
Steps:
This triggers the server to add a couple numbers to the array
Expected: OnAdd is called- it is not
A few seconds later, the server will remove these items
Expected: OnRemove is called for each- it's only called for one of them