Skip to content

Instantly share code, notes, and snippets.

@pravdomil
Last active April 7, 2020 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pravdomil/3c5a7595e2355cf651f47021fbdf3079 to your computer and use it in GitHub Desktop.
Save pravdomil/3c5a7595e2355cf651f47021fbdf3079 to your computer and use it in GitHub Desktop.
export function app<Msg, Model>(model: Model, updateFn: (msg: Msg, model: Model) => Model) {
return (msg: Msg) => {
defer(() => {
model = updateFn(msg, model)
})
}
}
export function defer(fn: () => void): void {
Promise.resolve().then(fn)
}
export function never(_: never): any {
throw new Error("Never say never!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment