Releases: beekai-oss/little-state-machine
Releases · beekai-oss/little-state-machine
Version 4.8.1
- update react 19 dependency
Version 4.8.0
Context
The new method will retrieve the latest store value when an action is performed, this is great for usage such as re-render is not required and yet you want to retrieve the newest store value.
Example
const update = (state: GlobalState, payload: string) => {
return {
...state,
value: payload
}
}
const { getState, actions } = useStateMachine({
update,
});
<button onClick={() => actions.update('test', { skipRender: true })}>Update<button≥
<button onClick={() => getState()}>Get State<button≥
Version 4.7.0
- introduce persist
none
option which you can skip saving data into session storage and this package can be use with React Native with this config set tonone
as well
createStore(
{
yourDetail: { firstName: '', lastName: '' } // it's an object of your state
},
{
// when 'none' is used then state is not persisted
// when 'action' is used then state is saved to the storage after store action is completed
// when 'beforeUnload' is used then state is saved to storage before page unload and is restored
// after next page load and then storage is cleared
persist?: 'action' // onAction is default if not provided
},
);
huge thanks to @snax4a
Version 4.6.0
- add new option for skip context re-render
const { actions } = useStateMachine()
// The following action will only update the store without flushing down a context re-render update
actions.updateStore({
test: 'data'
}, { skipRender: true })
v4.4.1
v4.4.0
Version 4.2.4
type update: allow actions payload to be optional
export type ActionsOutput<
TCallback extends AnyCallback,
TActions extends AnyActions<TCallback>
> = {
- [K in keyof TActions]: (payload: Parameters<TActions[K]>[1]) => void;
+ [K in keyof TActions]: (payload?: Parameters<TActions[K]>[1]) => void;
};
Version 4.2.3
fix: type issue with createStore
optional argument