xaviergonz / mobx-keystone

A MobX powered state management solution based on data trees with first class support for Typescript, support for snapshots, patches and much more
https://mobx-keystone.js.org
MIT License
541 stars 23 forks source link

Migration guide from Mobx-State-Trees #141

Open garrettg123 opened 4 years ago

garrettg123 commented 4 years ago

Hi,

I'd like to start by saying kudos for the AMAZING work with this project and massive improvement over MST. You deserve many pats on the back!

I have a small project so far (~3k LOC on the client) and am wondering how easy it would be to switch from MST. It would be very helpful and reassuring for anyone who is considering the switch to have some sort of migration guide (like a blog post or part of the official docs). I'd imagine there are a lot of people that will use this because MST has over 5k stars already. I see this library as being the successor to MST for anyone using Typescript.

Side note: because this repository isn't at v1 yet, I am also uncertain as to whether this is production-ready. I just thought it would be useful for you to know as I'm sure there will be others like me, and I believe these ideas could help MK grow.

Thanks!

xaviergonz commented 4 years ago

Thank you! I actually started this library after mantaining MST for a while (and I started it mostly because of the TypeScript pains to be honest).

If you can live with $modelId / $modelType in the snapshots it shouldn't be too hard to port to class models. If you require those fields not to be there then it can be a bit more difficult since you'd need to use functional models.

Either way it shouldn't be extremely hard (I did migrate a project way bigger than 3k LOC after all), since most concepts are shared across both libs.

PS: I'm thinking of moving it to v1 soon, just wanted to make sure the API was stable for a while before formalizing it.

xaviergonz commented 4 years ago

That being said, if somebody wants to create such a guide I'd be most grateful :)

nfour commented 4 years ago

@xaviergonz do you think it's feasible to create a compatibility layer for an existing MST tree, so that one model at a time can be converted to keystone?

terrysahaidak commented 4 years ago

@nfour I think it's way easier and faster to just convert the app from mst to keystone than building such a compatibility layer.

nfour commented 4 years ago

@nfour I think it's way easier and faster to just convert the app from mst to keystone than building such a compatibility layer.

For an individual, yes, but if the work was done to enable this for new users like myself through a support library, this would mean I wouldn't have to convert 1000's of lines of model code as an upfront cost, nor would I be "locked out" of MST model libraries or Keystone libraries in MST.

This is the kind of thing that made Typescript so popular.

garrettg123 commented 4 years ago

Yes, if there were a way to do this migration partially without having to fully migrate that would be an easy sell, like starting with one model, whereas right now I cannot justify the time to switch over.