reactive-streams-utils
reactive-streams-utils copied to clipboard
Stateful variants of functions
Currently, map, filter etc must be stateless, otherwise the returned builder can't be reused. We might consider adding stateful versions of them, ie, where the function is provided by a Supplier. This would then allow you to create things like a ProcessorBuilder<ByteBuffer, CharSequence> for decoding bytes into characters, that could be applied to many graphs, without having to create a new ProcessorBuilder each time.
We might also consider making the spi provide this, even if we don't offer it in the api, so that it can be added in future. The filter stage already allows stateful filtering, which is how drop and dropWhile are implemented.
We could also have a general stateful stage constructor in the API, which is a Supplier<Graph>, that gets supplied when the graph is built. This wouldn't need support in the spi.