PPTist/src/hooks/useAddHistorySnapshot.ts
pipipi-pikachu a1fba0dbea update
2020-12-20 20:23:46 +08:00

15 lines
342 B
TypeScript

import { useStore } from 'vuex'
import debounce from 'lodash/debounce'
import { State, ActionTypes } from '@/store'
export default () => {
const store = useStore<State>()
const addHistorySnapshot = debounce(function() {
store.dispatch(ActionTypes.ADD_SNAPSHOT)
}, 300, { trailing: true })
return {
addHistorySnapshot,
}
}