0.1.1 • Published 6 months ago

@practicaljs/ts-kit v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Usage

Create Reducer and Actions

  type User = {
    name: string,
    age: number
  }
  const UserActions = {
    setName: (state: User, {payload}: Action<string>) => {
      return { ...state, name: payload };
    }
  } satisfies ReducerActions<User>

  const [state, dispatch] = useReducer(createReducer(UserActions), initState)
  const actions = createActions(UserActions, dispatch)
  actions.setName('foo')
0.1.1

6 months ago

0.1.0

10 months ago