Any guidance on creating snapshots with vanilla MobX? #2890
Replies: 1 comment 2 replies
-
you could take a look at serializr or any other serialization library you
can find on the internet. I have to admit in most cases I personally just
handcraft it. Note that your constructor name mechanism will probably not
survive once your code is minified for production. Beyond that building the
inverse utility shouldn't be too hard if you give every class an empty
constructor and register them in some Map by name.
…On Mon, Apr 12, 2021 at 7:50 PM Joel Bohorquez ***@***.***> wrote:
Hi guys, hope all is well! I know that MST provides an easy way to
create/apply snapshots, but I like the simplicity of MobX and wondering
what would be the best way when combining multiple stores?
I did a recursive function that saves the entire state tree into a JSON
identifying each model with its object
[image: image]
<https://user-images.githubusercontent.com/19965325/114444996-2352e680-9b95-11eb-9aa4-c3f3cce287ee.png>
It returns something like this:
{
"__Model": "TodoStore",
"author": {
"__Model": "Author",
"name": "John Doe"
},
"todos": [
{
"__Model": "Todo",
"task": ""
}
]
}
Now I'm looking for a way to apply this to the main store, any idea if
createViewModel utility would help me on this?
Thanks!!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2890>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBH7ZXCZPQPL57ZN7X3TIM6IJANCNFSM42Z3BXIQ>
.
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
joelbqz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys, hope all is well! I know that MST provides an easy way to create/apply snapshots, but I like the simplicity of MobX and wondering what would be the best way when combining multiple stores?
I did a recursive function that saves the entire state tree into a JSON identifying each model with its object
It returns something like this:
Now I'm looking for a way to apply this to the main store, any idea if
createViewModel
utility would help me on this?Thanks!!
Beta Was this translation helpful? Give feedback.
All reactions