- Notifications
You must be signed in to change notification settings - Fork7.6k
Subject
ASubject is a sort of bridge or proxy that acts both as anSubscriber and as anObservable. Because it is a Subscriber, 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.
For more information about the varieties of Subject and how to use them, seethe ReactiveXSubject documentation.
When you use a Subject as a Subscriber, take care not to call itsonNext( ) method (or its otheron methods) from multiple threads, as this could lead to non-serialized calls, which violates the Observable contract and creates an ambiguity in the resulting Subject.
To protect a Subject from this danger, you can convert it into aSerializedSubject with code like the following:
mySafeSubject =newSerializedSubject(myUnsafeSubject );
Copyright (c) 2016-present, RxJava Contributors.
Twitter @RxJava |Gitter @RxJava