fsprojects / FSharp.Control.Reactive

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

Subscribe function #11

Closed ploeh closed 10 years ago

ploeh commented 10 years ago

Thank you for a great library.

I'd like to suggest a new function, which would look like this:

let Subscribe observer (observable : IObservable<'T>) =
    observable.Subscribe observer

The purpose is simply to enable a more idiomatic F# syntax for pipelining observables to an observer, like this:

c
|> Observable.map EnvelopWithDefaults
|> Subscribe reservationRequestObserver
|> request.RegisterForDispose

Perhaps there's already a way to do that, but I couldn't find it.

If you think this is an acceptable idea, I'll be happy to provide a pull request.

forki commented 10 years ago

How about this one:

/// Subscribes to the observable with the given observer
let subscribeObserver observer (observable: IObservable<'T>) =
    observable.Subscribe observer
forki commented 10 years ago

Released with 2.2.131002

ploeh commented 10 years ago

That was fast - thank you :)