Created
October 14, 2018 15:52
-
-
Save dbrattli/43a3e2e70547fec09067ae3d70689ee7 to your computer and use it in GitHub Desktop.
Promise Then Extension
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
// Make a new extension method on Promise | |
type Promise<'a> with | |
member this.Then(fn: 'a -> Promise<'b>) : Promise<'b> = | |
let newPromise = Promise<'b> () | |
this.Then(fun a -> | |
let tmpPromise = fn a | |
tmpPromise.Then(newPromise.Resolve).Catch(newPromise.Reject) | |
|> ignore | |
).Catch(newPromise.Reject) | |
|> ignore | |
newPromise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment