Last active
April 7, 2020 15:29
-
-
Save pravdomil/3c5a7595e2355cf651f47021fbdf3079 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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