Closed geccy25 closed 2 years ago
// writing and reading to disc is async
// redux docent support async operations inside Slice
// they need to be performed outside of redux and written back in an async callback
export function read() {
const { write } = periodSlice.actions
storage.read().then(p => store.dispatch(write(p)))
}
export function write(periods: Period) {
const { write } = periodSlice.actions
storage.write(periods).then(p => store.dispatch(write(p)))
}
export function remove(item: Period) {
const { write } = periodSlice.actions
storage.delete(item).then(periods => store.dispatch(write(periods)))
}
// eslint is disabled because useEffects needs to only run once and eslint
// doesn't compile the code with useEffect(()=>{},[])
useEffect(() => {
// eslint-disable-line
read() // eslint-disable-line
}, []) // eslint-disable-line
-> reusable Components