mobxjs / mobx-utils

Utility functions and common patterns for MobX
MIT License
1.19k stars 126 forks source link

Question: How to use ObservableGroupMap in MST? #284

Open tho-graf opened 3 years ago

tho-graf commented 3 years ago

Hi there,

I do my first little baby steps with mobx / MST and can't get ObservableGroupMap working with MST. Here is my example. I have an array in my state tree. This is by default an observable array, right? Is it correct to initialize the ObservableGroupMap in the view function once and read from it in a view function? Later I call the view function in an autorun. But the length of the (grouped) array is the same for ever.

https://codesandbox.io/s/competent-tu-1jyo8

Can anybody tell me what I am doing wrong?

Cheers Thomas

NaridaL commented 3 years ago

I had a look at this. The issue seems to be that in MST, list.todos isn't actually an observable array of {done: boolean}, but rather a Proxy around an observable array of MST's ObjectNodes around {done: boolean}.

As far as I can see, for this to work, OGM would need to be changed to add explicit MST support.