Add Observable.endWith?
See original GitHub issueI’m using Observable.startWith
but would also like to use a new method Observable.endWith
say (I suppose concat
is not available because of static method with same signature after erasure).
The driver for me is that my code (in java) is heaps uglier without it.
Suppose I have source1, source2 and I want to do some stuff to source1 and then append source2:
I have three options:
Use static concat
:
Observable.concat(source1.take(20).buffer(2,1).filter(myFilter), source2);
Use startWith
:
source2.startWith(source1.take(20).buffer(2,1).filter(myFilter));
or use a new endWith
method:
source1.take(20).buffer(2,1).filter(myFilter).endWith(source2);
The last one is much clearer. Am I overlooking something or can we can add this method to the api?
Perhaps a method like ``append` is better because it might seem strange to see multiple concatenated endWiths:
source1.endWith(source2).endWith(source3);
or
source1.append(source2).append(source3);
Issue Analytics
- State:
- Created 9 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
endWith - Learn RxJS
signature: endWith(an: Values): Observable ... If you want to start with a value instead, check out startWith ! ... Example 1: Basic endWith...
Read more >rxjs - Why isn't there a endWith operator in Rx? - Stack Overflow
I have come up with this solution, but is there anything better? This thing gets a bit hard to read for what it...
Read more >endWith - RxJS
Returns an observable that will emit all values from the source, then synchronously emit the provided value(s) immediately after the source completes.
Read more >RxJS Operators / Michael Pishchagin - Observable
defer(observableFactory: function(): SubscribableOrPromise): Observable ... endWith(an: Values): Observable. Array(6) ["begin", 1, 2, 3, "end", "✓"] ...
Read more >Observable | RxJS API Document - ReactiveX
Creates an Observable by using the addHandler and removeHandler functions to add and remove the handlers, with an optional selector function to project...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We now have
concatWith
as an instance method.You can now write code like this:
This outputs:
Actually, it would be great to also have
concatWithItem
, because we already have bothstartWith
andstartWithItem
, whileconcatWith
doesn’t have a similar shortcut to omit writingObservable.just
.