Unirx



It's a re-implementation of NET Reactive Extensions ( ReactiveX ) for Unity3D by Yoshifumi Kawai. ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming. A Subject is a sort of bridge or proxy that is available in some implementations of ReactiveX that acts both as an observer and as an Observable. UniRx (Reactive Extensions for Unity) is a reimplementation of the.NET Reactive Extensions. The Official Rx implementation is great but doesn't work on Unity and has issues with iOS AOT/IL2CPP compatibility. This library fixes those issues and adds some specific utilities for Unity.

A Subject is a sort of bridge or proxy that is available in some implementations of ReactiveX that acts both as an observer and as an Observable. Because it is an observer, it can subscribe to one or more Observables, and because it is an Observable, it can pass through the items it observes by reemitting them, and it can also emit new items.

Because a Subject subscribes to an Observable, it will trigger that Observable to begin emitting items (if that Observable is “cold” — that is, if it waits for a subscription before it begins to emit items). This can have the effect of making the resulting Subject a “hot” Observable variant of the original “cold” Observable.

See Also

  • To Use or Not to Use Subject from Dave Sexton’s blog
  • Advanced RxJava: Subject by Dávid Karnok
  • Using Subjects by Dennis Stoyanov

Varieties of Subject

Unirx Subject

There are four varieties of Subject that are designed for particular use cases. Not all of these are available in all implementations, and some implementations use other naming conventions (for example, in RxScala, what is called a “PublishSubject” here is known simply as a “Subject”):

AsyncSubject

See Also

BehaviorSubject

See Also

PublishSubject

ReplaySubject

See Also

Unirx unsubscribe

Language-Specific Information:

Unirx Pharmacy

If you have a Subject and you want to pass it along to some other agent without exposing its Subscriber interface, you can mask it by calling its asObservable method, which will return the Subject as a pure Observable.

See Also

  • Javadoc: AsyncSubject
  • Javadoc: BehaviorSubject
  • Javadoc: PublishSubject
  • Javadoc: ReplaySubject

If you have a Subject and you want to pass it along to some other agent without exposing its Subscriber interface, you can mask it by calling its asObservable method, which will return the Subject as a pure Observable.

See Also

SubjectUnirx vs unitask
  • Javadoc: AsyncSubject
  • Javadoc: BehaviorSubject
  • Javadoc: PublishSubject
  • Javadoc: ReplaySubject

TBD

Unirx Tutorial

See Also

Unirx Documentation

  • Reactive Extensions: AsyncSubject
  • Reactive Extensions: BehaviorSubject
  • Reactive Extensions: ReplaySubject