Created
May 22, 2016 13:06
-
-
Save rpominov/9b4e3f858b35905e66465211f783dc13 to your computer and use it in GitHub Desktop.
Task concept
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
| 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 | |
| } |
Author
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
Alt 2
Like
#1but withTask<L,R>.LandRonly for user's explicit "lefts" / "rights", catched exceptions never go there. Exceptions still go only intoonErrorcallback inrunAndCatchand can't be recovered from etc.And yeah, we don't need
onCancelcallback probably...