Add .flatMapEnd?
See original GitHub issueWe already have .flatMap & .flatMapError, adding .flatMapEnd seems like a logical continuation. It will be a more powerful alternative to .beforeEnd, which allows only to insert a value before end.
Inserting a value before end
// Before
foo.beforeEnd(() => 1)
// After
foo.flatMapEnd(() => Kefir.constant(1))
Inserting a error before end
// Before
// (will work only if foo does't contain other values,
// otherwise it will be even trickier)
foo.beforeEnd(() => 1).flatMap(Kefir.constantError)
// After
foo.flatMapEnd(() => Kefir.constantError(1))
Inserting multiple values
// Before
// (Will work only if foo does't contain other values,
// otherwise it will be even trickier)
foo.beforeEnd(() => 1).flatMap(() => Kefir.sequentially(1000, [1, 2, 3]))
// After
foo.flatMapEnd(() => Kefir.sequentially(1000, [1, 2, 3]))
Ignoring the end
// Before
foo.ignoreEnd()
// After
// (Suppose we'll have Kefir.neverEnd()
// similar to Kefir.never() but that also doesn't end)
foo.flatMapEnd(Kefir.neverEnd)
The 1 & 4 examples aren’t very convincing as current alternative is easier, but I still include them to better illustrate potential of .flatMapEnd.
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Java 8 Streams: Definitive Guide to flatMap() - Stack Abuse
The flatMap() operation returns a cummulative stream, generated from multiple other streams. The elements of the stream are created by applying ...
Read more >Project Reactor: map() vs flatMap() - Baeldung
This tutorial introduces the map and flatMap operators in Project Reactor. They're defined in the Mono and Flux classes to transform items ...
Read more >Why doesn't this map() or flatMap() finish the pipeline even ...
you get a Mono<Boolean> because ArrayList#add() returns a boolean. If you don't need the transformation, you can call doOnNext() . List<String> tokens =...
Read more >Stream flatMap() in Java with examples - GeeksforGeeks
Stream flatMap(Function mapper) returns a stream consisting of the results of replacing each element of this stream with the contents of a ...
Read more >Array.prototype.flatMap() - JavaScript - MDN Web Docs
The flatMap() method returns a new array formed by applying a given callback function to each element of the array, and then flattening...
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
Maybe something like this:
Here’s how I ended up handling it:
Can you see a better way?