=========== Disposables =========== Asynchronous disposables are similar to `IDisposable `_ but with the difference that it encapsulates an async dispose method called `DisposeAsync`. .. code:: fsharp type AsyncDisposable (cancel) = interface IAsyncDisposable with member this.DisposeAsync () = async { do! cancel () } In additon the following static members have been defined: - **Create** : ``(unit -> Async) -> IAsyncDisposable``, creates an ``IAsyncDisposable`` from an async cancel function. Same instantiating the object, but the return value here is anonymous. - **Empty** : ``unit -> IAsyncDisposable``, creates an empty disposable that will do nothing if it's disposed. - **Composite** : ``seq -> IAsyncDisposable``, creates a disposable from a sequence of disposables. If disposed then all the contained disposables will also be disposed. The ``SubscribeAsync`` method for async observables returns an async disposable, and to cancel the subscription you need to call the `DisposeAsync` method. .. code:: fsharp let xs = ofSeq <| seq { 1 .. 5 } let obv = MyObserver() let! subscription = xs.SubscribeAsync obv // Unsubscribe do! subscription.DisposeAsync ()