Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Stream splitting #3

Open
jroper opened this issue Mar 19, 2018 · 0 comments
Open

Stream splitting #3

jroper opened this issue Mar 19, 2018 · 0 comments

Comments

@jroper
Copy link
Member

jroper commented Mar 19, 2018

We might want to introduce some stream splitting functions. For example, a splitWhen function.

This functionality is generally only useful when doing parsing, where you parse some sort of header out of the stream, followed by a sub stream, then another header, etc.

Generally, the element that is split at needs to be accessed before consuming the sub stream. So the sub stream should make that element available, along with the rest of the stream. For example:

PublisherBuilder<SubStream<T>> splitWhen(Predicate<? super T> predicate);
class SubStream<T> {
  final T first;
  final PublisherBuilder<T> rest;
}

So, for each element where the predicate holds true (plus the first element), a SubStream is emitted, with first being that element, and rest being the remainder of the stream as long as the predicate holds false.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant