DEV Community

loading...

Discussion on: Beginners guide to mobx-state-tree in 5 minutes or less

Collapse
saadbashar profile image
Saad

Hi, Great article Matt! One question, let's say I am getting user info from API response and user info has lots of details. So in that case I need to create a user model first with all the data types and attributes first, right? So my model will be very big. What if the API adds/deletes a new attribute from user info? I need to update my model always according to that right?

Thanks again for the nice intro!

Collapse
mattruby profile image
Matt Ruby Author

Hi Saad,

Tough to get into that in a whirlwind five minute intro :-)

I'll visit things like that in future posts. But here are a few suggestions.

Take a look at mobx-state-tree.js.org/overview/types

For a key value grab bag, you can use types.map or if your dataset is totally wild west, you can use types.frozen.

I've hit on what you're up against. What I normally try to do is model as much as I can, and try to constrain the wild attributes into a separate grab bag.

Glad you enjoyed the article! I'll try to keep them coming.

Collapse
saadbashar profile image
Saad

Thank you so much for the quick response and helpful link. I will go through them. Hopefully will see you doing a series on this!