|
| 1 | +## RxJava v2 Design |
| 2 | + |
| 3 | +Terminology, principles, contracts, and other aspects of the design of RxJava v2. |
| 4 | + |
| 5 | +### Terminology & Definitions |
| 6 | + |
| 7 | +##### Hot |
| 8 | + |
| 9 | +When used to refer to a data source (such as an `Observable`), it means it does not have side-effects when subscribed to. |
| 10 | + |
| 11 | +For example, an `Observable` of mouse events. Subscribing to that `Observable` does not cause the mouse events, but starts receiving them. |
| 12 | + |
| 13 | +(Note: Yes, there are *some* side-effects of adding a listener, but they are inconsequential as far as the 'hot' usage is concerned). |
| 14 | + |
| 15 | +##### Cold |
| 16 | + |
| 17 | +When used to refer to a data source (such as an `Observable`), it means it has side-effects when subscribed to. |
| 18 | + |
| 19 | +For example, an `Observable` of data from a remote API (such as an RPC call). Each time that `Observable` is subscribed to causes a new network call to occur. |
| 20 | + |
| 21 | +##### Reactive |
| 22 | + |
| 23 | +Producer is in charge. Consumer has to do whatever it needs to keep up. |
| 24 | + |
| 25 | +##### Interactive |
| 26 | + |
| 27 | +Consumer is in charge. Producer has to do whatever it needs to keep up. |
| 28 | + |
| 29 | +##### Push |
| 30 | + |
| 31 | +Producer emits when it wishes to. Related to "reactive". Callbacks are an instance of push. |
| 32 | + |
| 33 | +##### Pull |
| 34 | + |
| 35 | +Consumer requests data when it wishes to. Related to "interactive". An `Iterable` is an instance of pull. |
| 36 | + |
| 37 | +##### Async Pull |
| 38 | + |
| 39 | +Consumer requests data when it wishes, and the data is then pushed when the producer wishes to. The Reactive Streams `Publisher` is an instance of "async pull", as is the 'AsyncEnumerable' in .Net. |
| 40 | + |
| 41 | +### RxJava & Related Types |
| 42 | + |
| 43 | +##### Observable |
| 44 | + |
| 45 | +... under discussion ... (related to Observable/Flowable debate) |
| 46 | + |
| 47 | +##### Observer |
| 48 | + |
| 49 | +Consumer of events without flow control. |
| 50 | + |
| 51 | +##### Publisher |
| 52 | + |
| 53 | +[Reactive Streams producer](https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.0/README.md#1-publisher-code) of data |
| 54 | + |
| 55 | +##### Subscriber |
| 56 | + |
| 57 | +[Reactive Streams consumer](https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.0/README.md#2-subscriber-code) of data. |
| 58 | + |
| 59 | +##### Subscription |
| 60 | + |
| 61 | +[Reactive Streams state](https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.0/README.md#3-subscription-code) of subscription supporting flow control and cancellation. |
| 62 | + |
| 63 | +##### Processor |
| 64 | + |
| 65 | +[Reactive Streams operator](https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.0/README.md#4processor-code) for defining behavior between `Publisher` and `Subscriber`. It must obey the contracts of `Publisher` and `Subscriber`, meaning it is sequential, serialized, and must obey `request(n)` flow control. |
| 66 | + |
| 67 | +##### Subject |
| 68 | + |
| 69 | +A "hot" data source that allows a producer to emit events and consumers to receive events in a multicast manner. |
| 70 | + |
| 71 | +It is "hot" because consumers subscribing to it does not cause side-effects, or affect the data flow in any way. It is push and reactive because the producer is fully in charge. |
| 72 | + |
| 73 | +##### Disposable |
| 74 | + |
| 75 | +A type representing work that can be cancelled or disposed. |
| 76 | + |
| 77 | + |
0 commit comments