You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an instance is re-used in many places, their callbacks are triggered only once, at places not easily predictable.
Failing test case
classPlayerextendsSchema{
@type("number")hp: number;}classStateextendsSchema{
@type(Player)player1: Player;
@type(Player)player2: Player;}conststate=newState();constplayer=newPlayer().assign({hp: 100});;state.player1=playerstate.player2=player;constdecodedState=Reflection.decode<State>(Reflection.encode(state));letnumTriggered=0;decodedState.player1.listen('hp',()=>numTriggered++);decodedState.player2.listen('hp',()=>numTriggered++);// THIS DOES NOT TRIGGERdecodedState.decode(state.encode());assert.strictEqual(decodedState.player1.hp,100);assert.strictEqual(decodedState.player2.hp,100);assert.strictEqual(2,numTriggered);// ERROR: 2 !== 1
In the example above, only the 1st .listen() callback is triggered.
This issue does not happen when cloning the instances, only when sharing the same instance - which will result in the instance being shared on the client-side as well.
The text was updated successfully, but these errors were encountered:
When an instance is re-used in many places, their callbacks are triggered only once, at places not easily predictable.
Failing test case
In the example above, only the 1st
.listen()
callback is triggered.This issue does not happen when cloning the instances, only when sharing the same instance - which will result in the instance being shared on the client-side as well.
The text was updated successfully, but these errors were encountered: