-
Notifications
You must be signed in to change notification settings - Fork 84
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
regression: s.end(true) failing to end stream? #176
Comments
Your problem is here: var sub = flyd.on(val => {
// this check ignores the initial call during subscription
if (!sub) return;
sub.end(true);
then();
}, s); You are assuming that the method passed to It seems the function you passed to
We can implement this generically as const drop = n => s => {
return flyd.combine(function(s, self){
if (--n < 0) self(s());
}, [s]);
}
const take = n => s => {
return flyd.combine(function(s, self) {
if (--n < 0) {
self.end(true);
return;
}
self(s());
}, [s])
} then to achieve the desired result you can utilise these methods like so: function on(s, then) {
var sub = s
.pipe(drop(1))
.pipe(take(1))
.map(_ => then());
return s();
} |
here is a fiddle demonstrating the resolution: https://jsfiddle.net/kfmtun8w/1/ For further context about this behaviour of flyd take a look at #160 and #163 |
awesome. thanks @nordfjord! |
hey @paldepind,
i'm having an issue with the latest flyd relative to a prior version. it seems like
s.end(true)
is failing to end the stream. in my case this is causing an infinite loop and stack explosion:v0.2.6
works:https://jsfiddle.net/tbtpoxwk/
master
(Maximum call stack size exceeded):https://jsfiddle.net/tbtpoxwk/1/
i haven't done a bisect to figure out which commit broke things :/
The text was updated successfully, but these errors were encountered: