Releases: teafuljs/teaful
Releases · teafuljs/teaful
0.4.0
- Rename lib to Fragstore
- Allow fragmented store in more levels
- Add callbacks
- Allow store and callbacks to Provider
BREAKING CHANGES
- Instead of
useUsername
now isuseStore.username()
. This allow multi fragmentuserStore.cart.price()
. And for all store isuseStore()
.
0.3.0
This introduces callbacks, that are executed for any property change. Is useful for example to fetch data to an endpoint after the state change, and roll back the state if the request fails.
const initialState = {
quantity: 2
}
// This is new
const callbacks = {
quantity: (newValue, prevValue, setValue) => {
// Update quantity from API
fetch('/api/quantity', { method: 'POST', body: newValue })
// Revert state change if it fails
.catch(e => setValue(prevValue))
}
}
const { Provider, useQuantity } = createStore(initialState, callbacks)
0.2.1
0.2.0
0.1.4
0.1.3
0.1.2
0.1.1
We are alive
Initial release 😊