-
-
Save Raynos/ff5032d26649fb3e51dd to your computer and use it in GitHub Desktop.
This file contains 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
// Minimal events | |
// type Listener := (value: Value) => void | |
// type Cancel := () => void | |
// type Event := (listener: Listener) => Cancel | |
// someEvent := Event<T> | |
function someEvent(listener) { | |
// notify listener when an event has occured | |
// want to signal completion? Invoke listener(Event.Completed) | |
// want to signal rejection? Invoke listener(new Error(reason)) | |
return function cancel() { | |
// remove listener from notification list. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment