Skip to content

Instantly share code, notes, and snippets.

@rozgo
Created December 2, 2014 10:26
Show Gist options
  • Save rozgo/2db80c908cbe085d82b3 to your computer and use it in GitHub Desktop.
Save rozgo/2db80c908cbe085d82b3 to your computer and use it in GitHub Desktop.
Async.AwaitObservable
#nowarn "40"
type Microsoft.FSharp.Control.Async with
static member AwaitObservable (evt : IObservable<'a>) =
Async.FromContinuations (fun (cont, econt, ccont) ->
let rec callback value =
sub.Dispose ()
cont value
and sub : IDisposable = evt.Subscribe callback
())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment