0.1.0 • Published 1 year ago
okahistory v0.1.0
okahistory
This is a convenient tool for the features of undo-redo operations.
usage
yarn add okahistory
import type { Reducer } from 'okahistory'
import { useHistory } from 'okahistory'
const state = { count: 0 }
const history = useHistory()
// define your reducers
const reducerA: Reducer<number, number> = {
redo(after) {
const before = state.count
state.count = after
return before
},
undo(before) {
state.count = before
},
}
const { dispatch, createAction } = history.defineReducers({ ACTION_A: reducerA })
// dispatch an action
dispatch(createAction('ACTION_A', 1))
// undo & redo
history.undo()
history.redo()
commnad
# install dependencies
$ yarn install
# lint
$ yarn lint
# test
$ yarn test [--watch]
# build
$ yarn build
publish
Create new release on Github.