Skip to content

Releases: beekai-oss/little-state-machine

Version 4.8.0

23 Sep 07:43
Compare
Choose a tag to compare

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

17 Sep 00:58
Compare
Choose a tag to compare
  • 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 to none 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

01 Sep 04:10
Compare
Choose a tag to compare
  • 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

29 May 04:42
bc10b65
Compare
Choose a tag to compare

4.4.1 (2022-05-29)

Bug Fixes

v4.4.0

29 May 04:26
f47288e
Compare
Choose a tag to compare

4.4.0 (2022-05-29)

Features

Version 4.2.4

15 Apr 09:32
Compare
Choose a tag to compare

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

21 Feb 03:01
Compare
Choose a tag to compare

fix: type issue with createStore optional argument

v4.2.1

08 Feb 05:57
800e931
Compare
Choose a tag to compare

4.2.1 (2022-02-08)

Bug Fixes

v4.2.0

27 Oct 01:03
42c186f
Compare
Choose a tag to compare

4.2.0 (2021-10-27)

Features

v4.1.2

05 Jun 23:43
Compare
Choose a tag to compare

4.1.2 (2021-06-05)

Bug Fixes