const Player = types.model({ game_object: types.frozen() }); const Zone = types.model({ players: types.map(Player) }) .actions(self => ({ addPlayer(params) { const playerGameObject = new PlayerGameObject(params); const newPlayer = Player.create({ game_object: playerGameObject }) self.players.set(params.socket_id, newPlayer) } }))
Later on I have
observe(store.zone, "players", change => { console.log("Store zone players changed!!", change) })
I am not sure why this isn't working. I've tried a similar thing with a string field instead of a Player and it did work!
Here's the code sandbox!
https://codesandbox.io/s/frosty-wave-wiy74?file=/src/index.js
2.1m questions
2.1m answers
60 comments
57.0k users