Created
January 5, 2014 22:37
-
-
Save haacked/8274988 to your computer and use it in GitHub Desktop.
Rx pipelining with F#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Reactive | |
open System.Reactive.Linq | |
let seq = [1; 2; 3; 4].ToObservable() | |
// Add curryable versions of Rx methods | |
let select (selector:'TSource -> 'TResult) (source:IObservable<'TSource>) = | |
Observable.Select(source, selector) | |
let where (predicate:'TSource -> bool) (source:IObservable<'TSource>) = | |
Observable.Where(source, predicate) | |
let newSeq = seq |> | |
where (fun num -> num % 2 = 0) |> | |
select (fun num -> num + 1) | |
ignore(newSeq.Subscribe(fun item -> printfn "%d" item)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment