Last active
October 1, 2015 10:08
-
-
Save Thorium/1972378 to your computer and use it in GitHub Desktop.
Simple Reactive Extensions Example
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
// Rx 1.0: | |
//#r "System.CoreEx" //for interactive and scripts | |
//#r "System.Reactive.dll" | |
//open System | |
//open System.Collections.Generic | |
//Rx 2.1: | |
#r "System.ComponentModel.Composition.dll" | |
#r "../packages/Rx-Interfaces.2.1.30214.0/lib/Net45/System.Reactive.Interfaces.dll" | |
#r "../packages/Rx-Core.2.1.30214.0/lib/Net45/System.Reactive.Core.dll" | |
#r "../packages/Rx-Linq.2.1.30214.0/lib/Net45/System.Reactive.Linq.dll" | |
open System.Reactive.Subjects | |
// --- | |
let observable = new Subject<int>() | |
let mySubscribe = | |
let interested = observable |> Observable.filter (fun x -> x%2=0) | |
interested.Subscribe(fun i -> Console.WriteLine("Hello " + i.ToString())) | |
let myYields = | |
observable.OnNext(1) | |
observable.OnNext(2) | |
observable.OnNext(3) | |
observable.OnNext(4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment