Effect CommunityEC
Effect Community16mo ago
1 reply
Matt Rossman

Flushing final state from `Stream.mapAccum`

Consider this Playground: https://effect.website/play#1c35dc72f871

I want to take a stream of characters and turn it into a stream of sentences. However when the stream ends, I want to include the remainder in my output even if it doesn't contain punctuation.
In the playground the stream outputs "One." and "Two.", but I also want to include the ending "Three"

With the standard Web Streams API I would use a flush() handler for this. I don't know when the stream ends inside Stream.mapAccum though, so that final accumulated state is lost.

How would I achieve this with effect's Streams?
Was this page helpful?