-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's the motivation for ending a stream? #216
Comments
Imagine you've got a timer and want to cancel it when listeners stop: function interval(ms: number) {
const s = stream()
let i = 0;
const interval = setInterval(()=> s(i++), ms)
s.end.map(()=> clearInterval(interval))
return s
}
interval(1000)
.pipe(take(4))
// 1-2-3-4 This can be extrapolated for arbitrary cleanup logic for e.g. web sockets |
I assume |
That sounds about right. Some of the built-in modules propagate ending downwards using a pattern like const takeUntil = (term, src) =>
flyd.endsOn(
flyd.merge(term, src.end),
flyd.combine((src, self) => {
self(src());
}, [src])
); |
Hi, long time user, first time writer.
Reading the docs again, I notice that there's a concept of ending a stream. What's the motivation for that? I can't think of a scenario, but I'm sure you had one in mind.
The text was updated successfully, but these errors were encountered: