Concepts
Last updated
Last updated
Reim is a pub/sub instance, so you can subscribe to it. When its state changes, it will notify the subscribers.
Unlike other state libraries that encourage you to use them when you have state that are global, Reim can be easily used as an HOC, kind of like Git where instead of one single global state tree, it promotes having multiple state trees.
A component does not necessarily need the whole state tree held by the store. This is where selector comes in to prevent unnecessary rerenders. When you subscribe to a Reim store, you can choose which state change actually matters to you.
What immutablility means to Reim is store.state.message = 'abc'
will throw an error. Instead you must do store.set({message: 'abc'})
.
This makes sure the mutations can be easily traced when errors happen. You can even rollback the changes, which is useful in devtools or debugging.