Skip to content
Simple Flow Control Library with Rx(Reactive Extensions).
Branch: master
Clone or download
Latest commit 0278390 Feb 26, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
RxFlow
.gitignore
LICENSE
README.md
RxFlow.sln

README.md

Simple Flow Control Library with Rx(Reactive Extensions).

##Supported Enviroment

  • .NET Framework 4.5
  • Windows 8
  • Windows Phone Silverlight 8
  • Xamarin.Android
  • Xamarin.iOS

##Simple Usage ####Junction Switch sequence.Switched value not flowed backward.

static void Sample1()
{
	var branchA = Branch.CreateBranch<int>(input =>
        input.Do(i => Console.WriteLine("branchA :" + i))
        .Subscribe());

    var branchB = Branch.CreateBranch<int>(input =>
        input.Do(i => Console.WriteLine("branchB :" + i))
        .Subscribe());

    Observable.Range(1, 10)
        .Junction(i => i % 2 == 0, branchA)
        .Junction(i => i % 3 == 0, branchB)
        .Subscribe();
}

/*output
* branchA :2
* branchB :3
* branchA :4
* branchA :6 // Not processed in branchB
* branchA :8
* branchB :9
* branchA :10
*/

####Distribution Distribute sequence.Distributed value flowed backward.

static void Sample2()
{
    var branchA = Branch.CreateBranch<int>(input =>
        input.Do(i => Console.WriteLine("branchA :" + i))
        .Subscribe());

    var branchB = Branch.CreateBranch<int>(input =>
        input.Do(i => Console.WriteLine("branchB :" + i))
        .Subscribe());

    Observable.Range(1, 10)
        .Distribution(i => i % 2 == 0, branchA)
        .Distribution(i => i % 3 == 0, branchB)
        .Subscribe();
}

/*output
* branchA :2
* branchB :3
* branchA :4
* branchA :6 //processed in branchA
* branchB :6 //processed in branchB
* branchA :8
* branchB :9
* branchA :10
*/

####Many to Many Many main sequences to many branches.

static void Sample3()
{
    var branchA = Branch.CreateBranch<int>(input =>
        input.Do(i => Console.WriteLine("branchA :" + i))
        .Subscribe());

    var branchB = Branch.CreateBranch<int>(input =>
        input.Do(i => Console.WriteLine("branchB :" + i))
        .Subscribe());

    Observable.Range(1, 5)
        .Distribution(i => i % 2 == 0, branchA)
        .Distribution(i => i % 3 == 0, branchB)
        .Subscribe();

    Observable.Range(6, 5)
        .Distribution(i => i % 2 == 0, branchA)
        .Distribution(i => i % 3 == 0, branchB)
        .Subscribe();
}

/*output
* branchA :2
* branchB :3
* branchA :4
* branchA :6
* branchB :6
* branchA :8
* branchB :9
* branchA :10
*/

####Branch to Branch

static void Sample4()
{
    var branchA = Branch.CreateBranch<int>(input =>
        input.Do(i => Console.WriteLine("branchA :" + i))
        .Subscribe());

    var branchB = Branch.CreateBranch<int>(input =>
        input.Do(i => Console.WriteLine("branchB :" + i))
        .Junction(i => i % 2 == 0, branchA)
        .Subscribe());

    Observable.Range(1, 10)
        .Junction(i => i % 3 == 0, branchB)
        .Subscribe();
}

/*output
branchB :3
branchB :6
branchA :6 //branchB to branchA
branchB :9
*/

##License MIT License

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.