Is there a way to create an observable from a sequence in F #?
The required behavior is that the observer who subscribes to the received observable receives all values of the sequence one at a time.
Change . The question can be framed as: is there an equivalent Rx.Observable.FromArray([1,2,3]), as shown here in F #?
Edit 2 : Thanks everyone. It took me a while to find the answer, only to find that Desco had already answered. For completeness, here's how it works:
open System.Linq
let observable = Observable.ToObservable [1..10]
let odds = observable |> Observable.filter (fun i -> i%2=1)
let disp = odds.Subscribe (fun i -> printfn "%d" i)
disp.Dispose ()
source
share