fsprojects / FSharp.Control.Reactive

Extensions and wrappers for using Reactive Extensions (Rx) with F#.
http://fsprojects.github.io/FSharp.Control.Reactive
Other
284 stars 58 forks source link

System.Reactive.Disposables wrappers #58

Closed bordoley closed 9 years ago

bordoley commented 9 years ago

It would be really useful if this library provided some F# friend module functions that wrap the Disposables supported by RX. Specifically, I'm thinking something like

module Disposables = let composite (disposables:IEnumerable<IDisposable) = let retval = new CompositeDisposable() for disposable in do retval.Add disposable retval :> IDisposable

panesofglass commented 9 years ago

Please send a PR. This would be great!

panesofglass commented 9 years ago

I think your snippet above is:

module Disposables =
    let composite (disposables: #seq<_>) =
        let retval = new CompositeDisposable()
        for disposable in disposables do
            retval.Add disposable
        retval :> IDisposable

I altered the signature to take any subclasses of IEnumerable<'T> since most F# code will provide generic lists, arrays, seqs, etc.