Releases: teafuljs/teaful
Releases · teafuljs/teaful
0.5.0
- Some improvements: rename Provider to Store, add types + fix eslint #14 (by @aralroca and @danielart)
BREAKING CHANGES
- We renamed
ProvidertoStorebecause after the reimplementation it is no longer mandatory to use it because it is no longer a provider, it only makes sense to redefine the store and callbacks. In the future, it will surely have more features.
0.4.1
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
useUsernamenow 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)