I’ve found myself wanting to complete a stream without having to raise an exception. To do this I use recoverWith and an empty source. This is quite cumbersome in Java (with a timeout exception as the trigger):
PartialFunction<Throwable, Source<EndDeviceEvents.Event, NotUsed>> completer =
new PFBuilder()
.match(TimeoutException.class, ex -> Source.empty()).build();
...
.recoverWithRetries(1, completer)
Has there been a consideration for a shortcut e.g.:
FYI, such completeWhen is exactly takeWhile(not condition)… I had proposed such complete when some time ago but we decided against it back then, though I would be ok with adding it — since people don’t discover it as they are looking for “complete”.
We can also address this problem by documentation; when we move the docs to “directive style”, we can make a page for operator/completeWhen.html which would just say "it is the same as takeWhile(!...) and direct there. We could this way fix this. Though since the ! makes it slightly different we could consider making it a real one hm