Skip to content

Instantly share code, notes, and snippets.

@rpominov
Created May 22, 2016 13:06
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 rpominov/9b4e3f858b35905e66465211f783dc13 to your computer and use it in GitHub Desktop.
Save rpominov/9b4e3f858b35905e66465211f783dc13 to your computer and use it in GitHub Desktop.
Task concept
type Result<L,R> =
| {T: 'Right', value: R}
| {T: 'Left', value: L}
| {T: 'Thrown', error: any}
| {T: 'Cancel'}
type Cancel = () => void
type RunHandler<L,R> =
| (result: Result<L,R>) => void
| {
Right?: (value: R) => void,
Left?: (value: L) => void,
Thrown?: (error: any) => void,
Cancel?: () => void,
}
type RunOptions = {
catch?: boolean
}
type Task<L,R> = {
run(handler: RunHandler<L,R>, options?: RunOptions): Cancel
}
@rpominov
Copy link
Author

Alt 3

Like #2 but catched exceptions go into L.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment