3 ms·
Ok, so I guess what I'm looking for here is how to implement our "database" as a client side data model that can do its thing, with the immutable structures (mo
by antihero 12y ago
Ok, so I guess what I'm looking for here is how to implement our "database" as a client side data model that can do its thing, with the immutable structures (mori?) so that React can figure out what's updated super quickly, and a way to make sure the app knows that it's been updated.
I need examples, basically!
Ideally I'd have an API to my datastore, which in turn would handle telling React what I've updated.
It feels like I'm just not "getting" something with Mori.
Say our state looks like this in a normal JS structure:
appState = {
widgets: [{name: 'blah', data: {'text': 'hello', articles: [{}]}}, ...}],
pageTitle: 'Hi!',
user: {name: 'Derp'},
notifications: 5
};
How would I even represent that with Mori?
Say I got a push from the server that I had 6 notifications, how would I change the state to represent this?
Say I wanted the widget to do an API call to update it's articles, and add any new article data to that. How would I do this?