Conversation
|
Also, Ive never actually used Travis CI. Would you mind giving me your 2 cents? I seems it just runs tests on each pull request? |
|
Thanks for this @ccorcos. Travis CI will run tests on your branch whenever you submit a pull request or push updates to your PR. Anyway, I've changed |
test/test.js
Outdated
There was a problem hiding this comment.
Don't call resume on either stream. You shouldn't need to. Just move the c.toArray above the write calls.
There was a problem hiding this comment.
then to array should call twice right? the first time it will be be [1] and the second will be [1,2] right?
There was a problem hiding this comment.
Nope. The callback will only be called once. toArray will wait until the source stream (c in this case) ends before emitting everything it saw.
|
hmm. this isn't working... 'async generator': function (test) {
function delay(push, ms, x) {
setTimeout(function () {
push(null, x);
}, ms);
}
var source = _(function (push, next) {
delay(push, 10, 1);
delay(push, 20, 2);
delay(push, 30, 3);
// should be stopped
delay(push, 40, 4);
delay(push, 50, 5);
delay(push, 60, _.nil);
})
var stopStream = _(function (push, next) {
delay(push, 35, 1);
delay(push, 45, _.nil);
})
var results = [];
source.takeUntil(stopStream).each(function (x) {
results.push(x);
});
this.clock.tick(10);
test.same(results, [1]);
this.clock.tick(10);
test.same(results, [1, 2]);
this.clock.tick(10);
test.same(results, [1, 2, 3]);
this.clock.tick(10);
test.same(results, [1, 2, 3]);
this.clock.tick(20);
test.same(results, [1, 2, 3]);
test.done();
}, |
|
it worked when I tried with 20... var stopStream = _(function (push, next) {
delay(push, 20, 1);
delay(push, 45, _.nil);
}) |
|
ahh, probably because stop isn't started until you get the first value from the source... that make sense |
|
Oy. That rebase in in the wrong spot... Any ideas how to fix that? |
|
P.S. If you want to check out what I've been working on: https://github.com/ccorcos/meteor-react-highland I threw you in the acknowledgements at the bottom. Thanks for all the help! And some discussion here: |
Try
This is a good point, and I can see this tripping people up. Is this reasonable behavior? For instance, a usecase for this transform may be as a timeout: "wait 30 seconds for There are two ways to do this:
I believe Rx's takeUntil does the latter, so we should probably do the same. It also fits with our laziness model. Another question: what happens if we pause after a var src = _(function (push, next) {
delay(push, 1, 10); // push 1 after 20 ms.
delay(push, 2, 20);
delay(push, _.nil, 30);
});
var selector = _(function (push, next) {
delay(push, _.nil, 25);
});
src.takeUntil(selector).toArray(_.log);
// => [1, 2]
src.takeUntil(selector).consume(function (err, x, push, next) {
push(err, x);
if (x !== _.nil) {
// This effectively pauses the source for 20 ms.
setTimeout(next, 20);
}
}).toArray(_.log);
// => [1]We'd get different results because the This is more of a problem than I thought... @ccorcos, what do you think? Highland collaborator folks (if you see this), any thoughts? |
|
Instinctively I'd lean towards a solution that gives a guaranteed result in all cases but it's a good point that this compromises our laziness and with a particularly fast stream that buffer could become quite large quite quickly. As long as we detail the behaviour clearly in the docs, I don't think it's much of a problem. |
|
Makes sense. Plus, you can always retroactively buffer, but you can't take back laziness. @ccorcos Do you think you can make the appropriate changes? I can take over if you don't have the time. |
|
Hey, I fixed the rebase... Not sure why that worked but it did! |
|
I think takeUntil makes sense as is. In terms of buffering, I'm not sure how you'd do that but it makes sense as well |
Hey, I thought I'd add some of the functions you've been helping me to this library.
Some of the tests fail with testling, but they seem to be outside the code I wrote. There are also some linting errors, but also outside the code I wrote. Anyways, let me know what you think.