🌶 350b / 650b state container with component actions for Preact & React
This is a bugfix release, in particular addressing the React and Devtools integrations.
connect()
(#50, thanks @vincentaudebert & everyone)/devtools
entry being missing from the published npm package in 3.0.3 (#55, thanks @dioptre)devtools()
now returns the store you pass it (#56, thanks @ouzhenkun)contextTypes
for React build (#38)setState(null)
throwing warning (thanks @srph)componentWillMount()
not triggering a re-render (#45, thanks @lilijialiang)This release just fixes the build & package that was released for 3.0.0, which contained some errors.
Unistore now supports React!
unistore
is now purely the implementation of createStore()
unistore/preact
is now { Provider, connect }
for Preact.unistore/react
is { Provider, connect }
for React.unistore/full/preact
to access the original single-file moduleWe've switched to Microbundle, check it out.
store.subscribe()
now returns an unsubscribe function! (#22, thanks @cristianbote)store.action(action)
API for creating store-bound actions (like connect()
does):let store = createStore()
store.subscribe(console.log) // log all store updates
// We start with a pure function, as you might pass to connect():
let increment = ({ count }) => ({ count: count + 1 });
// Passing that to createAction() returns a handler like you would get from connect():
let incrementAction = store.createAction(increment)
// Calling the action applies it to the store:
incrementAction() // logs { count: 1 }
createStore()
instead of just undefined
.New: Built-in support for async functions and actions that return promises!
connect('foo', {
async getFoo(state) {
return { foo: await (await fetch('/foo')).json() }
}
})