Reim.js
:thinking: Why another state library?
:metal: Update state by simply mutating it, thanks to immer
:closed_lock_with_key: Immutable state
:zap: Small, 6kb gzip + minified
:star2: Typing support for Typescript & Flow
:atom_symbol: Supports Redux Dev Tools
:book: How to use
Then use useReim
just like other React hooks :
or use <State/>
for some cases:
Table of Contents
reim
reim
reim(state | store, {actions?: Actions, name?: string})
reim(state | store, {actions?: Actions, name?: string})
Returns a new Reim
store.
An action is simple a function that returns a state updater.
For example:
Then just use it as a method:
filter(getter: {[name]: state => any} | state => any | keyof typeof state)
filter(getter: {[name]: state => any} | state => any | keyof typeof state)
Gets current snapshot of store
subscribe(fn, {filter})
subscribe(fn, {filter})
fn
gets called on change. You can unsubscribe(fn)
to stop subscription.
reim.snapshot()
reim.snapshot()
Returns snapshot of all stores created
reim.stringify()
reim.stringify()
Returns JSON.stringify
-ed snapshot of all stores created, safe for injecting
reim.preload(snapshot)
reim.preload(snapshot)
Used in client side for preloading states
react-reim
react-reim
<State/>
<State/>
initial
initial
Initial value of the store. The store is resets if initial value is changed.
store
store
Receives a Reim
store, initial
is ignored if store
is provided
actions
actions
Same as actions
in reim()
filter
filter
Same as filter
in reim()
useReim(store | state, {filter, actions})
useReim(store | state, {filter, actions})
Returns [snapshot, actions]
:heart: Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
:page_with_curl: License
MIT © IniZio
Last updated