Skip to content

Instantly share code, notes, and snippets.

@icorbrey
Created July 19, 2021 18:37
Show Gist options
  • Save icorbrey/72044c1e0191c811630316dd1fe6f5c2 to your computer and use it in GitHub Desktop.
Save icorbrey/72044c1e0191c811630316dd1fe6f5c2 to your computer and use it in GitHub Desktop.
import { writable } from 'svelte/store'
export const reducible = (reducer, initialState) =>
{
const { subscribe, update } = writable(initialState)
const dispatch = action =>
update(state => reducer(state, action))
return {
subscribe,
dispatch,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment