0no-co / wonka

šŸŽ© A tiny but capable push & pull stream library for TypeScript and Flow
MIT License
709 stars 29 forks source link

Add makeReplaySubject source #75

Closed EliaECoyote closed 2 years ago

EliaECoyote commented 4 years ago

This should act as a subject, with the addition of emitting immediately old values to new subscribers, in FIFO order.

The api could look like:

let makeReplaySubject: (bufferSize: int) => subjectT('a) = ....;

// example:
let subject = makeReplaySubject(5);

I'm currently working on a PR, @kitten please tell me if you think this could be useful!

kitten commented 4 years ago

I was considering to add this already, since we use this in urql with some custom code!

Feel free to open a PR! Iā€™d be happy to review this and get this feature in šŸ‘šŸ™Œ