-
Hi guys! I'm working on a RN application, and we use MobX extensively (although we probably have a better way of doing it, that's for a different discussion 😅). I stumbled upon a use-case where I want to persist/load state to/from AsyncStorage. To do that, I implemented a custom reviver/replacer for JSON.parse/stringify.
This works nicely for Here's a gist containing the current code with the workaround, and the previous code that does not work (because the It means that without extra context, I can't know if I'm working with an observable value or not. My current workaround is to parse it at the containing object level, which obviously hurts performance but given our current scale, it's not hurting us too badly. Let's talk about what could be possible ways of handling this. A possible solution I thought of was to mark the output of the observable objects' |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Looks like I think you can check the original type in |
Beta Was this translation helpful? Give feedback.
Looks like
toJSON
impl was added in 6.0, dunno what was the reasoning here.I think you can check the original type in
replacer
usingthis
:isObservableMap(this[key])
.