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
I've just read the DESIGN.md and noticed some things that I could do to improve the quality of the DESIGN.md. So as a result of my "proofreading" I mainly:
- Added periods at the ending of some sentences.
- Did case matching of certain types and terms. e.g. `OnSubscribe` -> `onSubscribe` OR flowable -> `Flowable`.
Hope it helps! 😄
Lazy representation of a unit of work that can complete or fail
222
+
Lazy representation of a unit of work that can complete or fail.
223
223
224
224
- Semantic equivalent of `Observable.empty().doOnSubscribe()`.
225
225
- Alternative for scenarios often represented with types such as `Single<Void>` or `Observable<Void>`.
226
226
227
227
Usable for:
228
228
229
-
-sync or async
230
-
- 0 items
229
+
-Sync or async.
230
+
- 0 items.
231
231
232
232
*Type Signature*
233
233
@@ -325,9 +325,9 @@ 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 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.
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
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`
330
+
Instead of the indirection of an `onSubscribe` and `lift`, operators are to be implemented by extending the base classes. For example, the `map`
331
331
operator will look like this:
332
332
333
333
```java
@@ -353,36 +353,36 @@ public final class FlowableMap<T, R> extends Flowable<R> {
353
353
}
354
354
```
355
355
356
-
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.
356
+
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.
357
357
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.
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.
359
359
360
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.*)
361
361
362
362
Therefore, new standard factory methods will try to address the common entry point requirements.
363
363
364
364
The `Flowable` will contain the following `create` methods:
365
365
366
-
-`create(SyncGenerator<T, S>)`: safe, synchronous generation of signals, one-by-one
367
-
-`create(AsyncOnSubscribe<T, S>)`: batch-create signals based on request patterns
368
-
-`create(Consumer<? super FlowEmitter<T>>)`: 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.).
369
-
-`createSingle(Consumer<? super SingleEmitter<T>>)`: relay a single value or error from other reactive sources (i.e., addListener callbacks)
370
-
-`createEmpty(Consumer<? super CompletionEmitter>)`: signal a completion or error from valueless reactive sources
366
+
-`create(SyncGenerator<T, S>)`: safe, synchronous generation of signals, one-by-one.
367
+
-`create(AsyncOnSubscribe<T, S>)`: batch-create signals based on request patterns.
368
+
-`create(Consumer<? super FlowEmitter<T>>)`: 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.).
369
+
-`createSingle(Consumer<? super SingleEmitter<T>>)`: relay a single value or error from other reactive sources (i.e. addListener callbacks).
370
+
-`createEmpty(Consumer<? super CompletionEmitter>)`: signal a completion or error from valueless reactive sources.
371
371
372
372
The `Observable` will contain the following `create` methods:
373
373
374
-
-`create(SyncGenerator<T, S>)`: safe, synchronous generation of signals, one-by-one
375
-
-`create(Consumer<? super FlowEmitter<T>>)`: 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.).
376
-
-`createSingle(Consumer<? super SingleEmitter<T>>)`: relay a single value or error from other reactive sources (i.e., addListener callbacks)
377
-
-`createEmpty(Consumer<? super CompletionEmitter>)`: signal a completion or error from valueless reactive sources
374
+
-`create(SyncGenerator<T, S>)`: safe, synchronous generation of signals, one-by-one.
375
+
-`create(Consumer<? super FlowEmitter<T>>)`: 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.).
376
+
-`createSingle(Consumer<? super SingleEmitter<T>>)`: relay a single value or error from other reactive sources (i.e. addListener callbacks).
377
+
-`createEmpty(Consumer<? super CompletionEmitter>)`: signal a completion or error from valueless reactive sources.
378
378
379
379
The `Single` will contain the following `create` method:
380
380
381
-
-`create(Consumer<? super SingleEmitter<T>>)`: relay a single value or error from other reactive sources (i.e., addListener callbacks)
381
+
-`create(Consumer<? super SingleEmitter<T>>)`: relay a single value or error from other reactive sources (i.e. addListener callbacks).
382
382
383
383
The `Completable` will contain the following `create` method:
384
384
385
-
-`create(Consumer<? super CompletionEmitter>)`: signal a completion or error from valueless reactive sources
385
+
-`create(Consumer<? super CompletionEmitter>)`: signal a completion or error from valueless reactive sources.
386
386
387
387
388
388
The first two `create` methods take an implementation of an interface which provides state and the generator methods:
@@ -509,10 +509,10 @@ There are two main levels of operator fusion: *macro* and *micro*.
509
509
510
510
Macro fusion deals with the higher level view of the operators, their identity and their combination (mostly in the form of subsequence). This is partially an internal affair of the operators, triggered by the downstream operator and may work with several cases. Given an operator application pair `a().b()` where `a` could be a source or an intermediate operator itself, when the application of `b` happens in assembly time, the following can happen:
511
511
512
-
-`b` identifies `a` and decides to not apply itself. Example: `empty().flatMap()` is functionally a no-op
512
+
-`b` identifies `a` and decides to not apply itself. Example: `empty().flatMap()` is functionally a no-op.
513
513
-`b` identifies `a` and decides to apply a different, conventional operator. Example: `just().subscribeOn()` is turned into `just().observeOn()`.
514
514
-`b` decides to apply a new custom operator, combining and inlining existing behavior. Example: `just().subscribeOn()` internally goes to `ScalarScheduledPublisher`.
515
-
-`a` is `b` and the two operator's parameter set can be combined into a single application. Example: `filter(p1).filter(p2)` combined into `filter(p1 && p2)`
515
+
-`a` is `b` and the two operator's parameter set can be combined into a single application. Example: `filter(p1).filter(p2)` combined into `filter(p1 && p2)`.
516
516
517
517
Participating in the macro-fusion externally is possible by implementing a marker interface when extending `Flowable`. Two kinds of interfaces are available:
518
518
@@ -540,7 +540,7 @@ Currently, two main kinds of micro-fusion opportunities are available.
540
540
541
541
###### 1) Conditional Subscriber
542
542
543
-
This extends the RS `Subscriber`interface with an extra method: `boolean tryOnNext(T value)` and can help avoiding small request amounts in case an operator didn't forward but dropped the value. The canonical use is for the `filter()` operator where if the predicate returns false, the operator has to request 1 from upstream (since the downstream doesn't know there was a value dropped and thus not request itself). Operators wanting to participate in this fusion have to implement and subscribe with an extended Subscriber interface:
543
+
This extends the RS `Subscriber`interface with an extra method: `boolean tryOnNext(T value)` and can help avoiding small request amounts in case an operator didn't forward but dropped the value. The canonical use is for the `filter()` operator where if the predicate returns false, the operator has to request 1 from upstream (since the downstream doesn't know there was a value dropped and thus not request itself). Operators wanting to participate in this fusion have to implement and subscribe with an extended `Subscriber` interface:
The second category is when two (or more) operators share the same underlying queue and each append activity at the exit point (i.e., poll()) of the queue. This can work in two modes: synchronous and asynchronous.
565
+
The second category is when two (or more) operators share the same underlying queue and each append activity at the exit point (i.e.`poll()`) of the queue. This can work in two modes: synchronous and asynchronous.
566
566
567
-
In synchronous mode, the elements of the sequence is already available (i.e., a fixed `range()` or `fromArray()`, or can be synchronously calculated in a pull fashion in `fromIterable`. In this mode, the requesting and regular onError-path is bypassed and is forbidden. Sources have to return null from `pull()` and false from `isEmpty()` if they have no more values and throw from these methods if they want to indicate an exceptional case.
567
+
In synchronous mode, the elements of the sequence is already available (i.e. a fixed `range()` or `fromArray()`, or can be synchronously calculated in a pull fashion in `fromIterable`. In this mode, the requesting and regular onError-path is bypassed and is forbidden. Sources have to return null from `pull()` and false from `isEmpty()` if they have no more values and throw from these methods if they want to indicate an exceptional case.
568
568
569
569
In asynchronous mode, elements may become available at any time, therefore, `pull` returning null, as with regular queue-drain, is just the indication of temporary lack of source values. Completion and error still has to go through `onComplete` and `onError` as usual, requesting still happens as usual but when a value is available in the shared queue, it is indicated by an `onNext(null)` call. This can trigger a chain of `drain` calls without moving values in or out of different queues.
570
570
@@ -588,10 +588,10 @@ For performance, the mode is an integer bitflags setup, called early during subs
588
588
589
589
Since RxJava 2.x is still JDK 6 compatible, the `QueueSubscription` can't itself default unnecessary methods and implementations are required to throw `UnsupportedOperationException` for `Queue` methods other than the following:
590
590
591
-
-`poll()`
592
-
-`isEmpty()`
593
-
-`clear()`
594
-
-`size()`
591
+
-`poll()`.
592
+
-`isEmpty()`.
593
+
-`clear()`.
594
+
-`size()`.
595
595
596
596
Even though other modern libraries also define this interface, they live in local packages and thus non-reusable without dragging in the whole library. Therefore, until externalized and standardized, cross-library micro-fusion won't happen.
0 commit comments