Replies: 3 comments 10 replies
-
Perhaps have a look at mobx-state-tree which has the concept of patches. Instead of transmitting commands, you are transmitting store modifications. You can easily transmit these patches and apply them to other stores. Technically, you can do this without MST, just |
Beta Was this translation helpful? Give feedback.
-
I would consider using redux's |
Beta Was this translation helpful? Give feedback.
-
Thanks for the replies, I'll look into those approaches. So far what I did was I'm converting the functions I need to take one object argument only, and then I can wrap the functions like this:
This basically makes a JSON for each function call like this:
It works, but as @urugator said this string based approach will probably not work on minified sources. Is there any way to solve this? For example can I make a map like this?
would this work? And if this does, how can I apply it back on the receiving side? Right now I'm using the following which works great in development:
|
Beta Was this translation helpful? Give feedback.
-
I've an app using MobX strict mode, with all important actions having their own functions (so no runInAction).
I'm trying to make the app multi-user aware using socket.io, and for this, I'd like to catch action calls with their arguments, then I'd run the same functions on other users' computers. So say, one user calls
setColor(objectId, 'red')
, I'd transmit `{command: 'setColor', args: ['red']} over socket.io and then all other user would have this action applied in real time.I've seen that
spy()
can do this, but I'd need it in production. Also I don't need it to be nested/recursive, I'm looking to capture the top level actions and serialize them to JSON.How can I do this?
Beta Was this translation helpful? Give feedback.
All reactions