0.2.0 • Published 3 years ago

@use-rematch/core v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

@use-rematch/core

npm

install

pnpm i @use-rematch/core

usage

create hook in compnent without dispatch types

import { useRematch } from '@use-rematch/core';

const [state, dispatch] = useRematch({
  name: '@use-rematch/core',
  state: {
    cnt: 0,
    loading: false,
  },
  reducers: {
    add: (state, payload?: number) => {
      return {
        ...state,
        cnt: payload ? state.cnt + payload : state.cnt + 1,
      };
    },
    toggleLoading: (state) => {
      return {
        ...state,
        loading: !state.loading,
      };
    },
  },
  effects: {
    async asyncAdd(payload: number, state: State) {
      this.toggleLoading();
      setTimeout(async () => {
        this.add(payload);
        this.toggleLoading();
      }, 1000);
    },
  },
});
0.2.0

3 years ago

0.1.0

4 years ago

0.0.6-alpha.1

5 years ago

0.0.6-alpha.0

5 years ago

0.0.5-alpha.12

5 years ago

0.0.5-alpha.11

5 years ago

0.0.5-alpha.9

5 years ago

0.0.5-alpha.2

5 years ago

0.0.5-alpha.3

5 years ago

0.0.5-alpha.4

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago