You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DESIGN.md
+58-8Lines changed: 58 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -325,24 +325,61 @@ In the addition of the previous rules, an operator for `Flowable`:
325
325
326
326
### Creation
327
327
328
-
Unlike RxJava 1.x, 2.x base classes are abstract and stateless and generally no longer wrap an `OnSubscribe` callback - this saves allocation in assembly time without limiting the expressiveness. Operator methods and standard factories still live as final on the base classes.
328
+
Unlike RxJava 1.x, 2.x base classes are to be abstract, stateless and generally no longer wrap an `OnSubscribe` callback - this saves allocation in assembly time without limiting the expressiveness. Operator methods and standard factories still live as final on the base classes.
329
+
330
+
Instead of the indirection of an `OnSubscribe` and `lift`, operators are to be implemented by extending the base classes. For example, the `map`
Since Java still doesn't have extension methods, "adding" more operators can only happen through helper methods such as `lift(C -> C)` and `compose(R -> P)` where `C` is the default consumer type (i.e., `rs.Subscriber`), `R` is the base type (i.e., `Flowable`) and `P` is the base interface (i.e., `rs.Publisher`). As before, the library itself may gain or lose standard operators and/or overloads through the same community process.
331
357
332
-
In concert, `create(OnSubscribe)` will not be available; standard operators extend the base types directly. The conversion of other RS-based libraries will happen through the `Flowable.wrap()` static method.
358
+
In concert, `create(OnSubscribe)` will not be available; standard operators extend the base types directly. The conversion of other RS-based libraries will happen through the `Flowable.wrap(Publisher<T>)` static method.
333
359
334
360
(*The unfortunate effect of `create` in 1.x was the ignorance of the Observable contract and beginner's first choice as an entry point. We can't eliminate this path since `rs.Publisher` is a single method functional interface that can be implemented just as badly.*)
335
361
336
362
Therefore, new standard factory methods will try to address the common entry point requirements:
337
-
-`create(SyncOnSubscribe)` to safe, synchronous generation of signals, one-by-one
338
-
-`create(AsyncOnSubscribe)` to batch-create signals based on request patterns
363
+
-`create(SyncGenerator<T, S>)` to safe, synchronous generation of signals, one-by-one
364
+
-`create(AsyncGenerator<T, S>)` to batch-create signals based on request patterns
339
365
-`create(Consumer<? super SingleEmitter<T>>)` to relay a single value or error from other reactive sources (i.e., addListener callbacks)
340
-
-`create(Consumer<? super FlowEmitter<T>>)` to relay multiple values or error from multi-valued reactive-sources (i.e., button-clicks) while also give flow control options right there (buffer, drop, error, etc.).
366
+
-`create(Consumer<? super FlowEmitter<T>>)` to relay multiple values or error from multi-valued reactive-sources (i.e., button-clicks) while also give flow control options right there (buffer, drop, error, etc.).
367
+
-`create(Consumer<? super CompletionEmitter>)` signal a completion or error from valueless reactive sources
368
+
369
+
The following table lists where these create methods will be available in respect of the base types:
By extending the base classes, operator implementations would loose the tracking/wrapping features of 1.x. To avoid this, the methods `subscribe(C)` will be final and operators have to implement a protected `subscribeActual` (or any other reasonable name).
0 commit comments