Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 2.38 KB

README.md

File metadata and controls

34 lines (28 loc) · 2.38 KB

Unirx Playground

A Unity playground for UniRx visualization inspired by rxmarbles.com.

Usage

After downloading the source code simply press play on the MainScene. The default choice is a SelectMany visualization which is one of the prepared examples. Check out other prepared examples in the Example script. You can write your own examples in this class and run them by changing exampleId in the inspector.

Select Many Example Visualization

How does this work?

Observable usage normally would look something like this:

SomeObservable
    .UniRxExtensionMethod1()
    .UniRxExtensionMethod2()
    .Subscribe(value => OnNext(value))
    .AddTo(this);

To visualize an observable you need to convert it to IObservable<RxMessageVisualizationData>. Any observable of this type can be visualized by the Visualize extension method.

SomeObservable
    .UniRxExtensionMethod1()
    .UniRxExtensionMethod2()
    .AsVisualizationDataObservable()
    .Visualize("Timeline Title")
    .Subscribe()
    .AddTo(RxTimelineManager.Main.DisposeBag);

The conversion to IObservable<RxMessageVisualizationData> can be done easily via the AsVisualizationDataObservable extension method. Without any given parameters the color will be a random color chosen at the beginning and the shown number will be an increasing integer starting from 1. If you want to keep any of the information that was contained in the original message you need to provide a selector method that will put it into the integer value or color of a message node.

There is no need to catch any messages in the subscription since all callbacks are visualized but it can still be used for debug purposes.

All subscriptions have to be destroyed at the end of the visualization in order to stop displying incoming messages. This can be ensured by adding them to RxTimelineManager.Main.DisposeBag.

All of this is necessary for the RxTimelineManager to properly invoke the Do, DoOnCompleted and DoOnError methods and add put corresponding markers on correct timelines.