Skip to content

Releases: beekai-oss/little-state-machine

v4.1.1

05 Jun 09:55
Compare
Choose a tag to compare

4.1.1 (2021-06-05)

Bug Fixes

v4.1.0

25 Feb 10:13
aff582d
Compare
Choose a tag to compare

4.1.0 (2021-02-25)

Features

  • Add action name & payload to middleware args (#82) (aff582d), closes #81

v4.0.2

17 Feb 23:41
df1f780
Compare
Choose a tag to compare

4.0.2 (2021-02-17)

Bug Fixes

  • Update middlewares only if available (#79) (df1f780)

Version 4.0.1

01 Feb 00:19
4648bf8
Compare
Choose a tag to compare

fix: Handle Chrome errors when cookies are disabled (#72)

Version 4.0.0-rc.2

18 Dec 09:02
Compare
Choose a tag to compare
  • support strict type

You can create a global.d.ts file to declare your GlobalState's type.

declare module 'little-state-machine' {
  interface GlobalState {
    yourDetail: {
      name: string;
    };
  }
}
import * as React from 'react';
import {
  createStore,
  useStateMachine,
  StateMachineProvider,
  GlobalState,
} from 'little-state-machine';

createStore({
  yourDetail: { name: '' },
});

const updateName = (state: GlobalState, payload: { name: string }) => ({
  ...state,
  yourDetail: {
    ...state.yourDetail,
    ...payload,
  },
});

const YourComponent = () => {
  const { actions, state } = useStateMachine({
    updateName
  }));

  return (
    <div onClick={() => actions.updateName({ name: 'Kotaro' })}>
      {state.yourDetail.name}
    </div>
  );
};

const App = () => (
  <StateMachineProvider>
    <YourComponent />
  </StateMachineProvider>
);

Version 4.0.0

18 Dec 11:29
Compare
Choose a tag to compare

⭐️ Version 4.0.0

  • Better TS support
  • Much smaller bundle size
  • Consistent and simplified API

Version 3.1.4

08 Dec 22:56
Compare
Choose a tag to compare
  • fix actions with useMemo for useEffect dep

Version 4.0.0-rc.0

13 Nov 09:38
Compare
Choose a tag to compare

New

  • craeteStore new config
export type StateMachineOptions = {
  name: string;
  middleWares: MiddleWare[];
  storageType?: Storage;
};

create({
}, options: StateMachineOptions)
  • Better TS support
// accept generic for global store type, and consistent actions
const { actions } = useStateMachine<GlobalStoreType>({
  updateName,
  updateLocaiton,
});
  • Tiny 767B

Breaking Changes

  • syncStores is removed
  • useStateMachine removed action and consistently using { actions }
  • clean and simple API, removed setStorageType

export { createStore, StateMachineProvider, useStateMachine };

Version 3.1.3

08 Nov 09:52
Compare
Choose a tag to compare
  • fix the issue with session storage check which broke gatsbyjs

Version 3.1.2

20 Oct 05:11
Compare
Choose a tag to compare

fix: added check for disabled session storage (#58)