Coder Social home page Coder Social logo

unirx-playground's Introduction

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.

unirx-playground's People

Contributors

jacykow avatar

Stargazers

Patryk Piotrowski avatar Adam Hill avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.