Closed BerndWessels closed 7 years ago
Hey,
The problem in your code is that you are using Object.assign with immutable objects. I am sure that is making some parts not to update.
Instead, try to do something like.
state.app.human[0].set({lastName: 'Wessels', dog: state.app.dog[99]});
That will keep the reference to your dog in the store, instead of creating a new object with the dog. Also a bit below:
state.app.dog[99].set({age:88});
That will edit the same dog that you were referencing before, so your human will be updated too.
I try to have my own kind of Entity System stored in Freezer Store.
But my Entity Objects have relations - here is an example on how I got it to work in Freezer:
at the end
state.app.human[0]
is correctly{"lastName":"Wessels","dog":{"age":88,"name":"Brutus"},"firstName":"Bernd"}
But this needs
transact()
which I am not sure about the performance if the Entity tree is very big.I tried this, but it didn't work:
but at the end
state.app.human[0]
is only{"lastName":"Wessels","dog":{"name":"Brutus"},"firstName":"Bernd"}
even though
state.app.dog[99]
is{"age":88,"name":"Brutus"}
Basically what I am asking is - how can I make sure that object references are preserved / distributed in freezer properly and with the best performance.