Closed Announcement closed 8 years ago
I'm not surprised. latest
always emits the latest seen value. Even if it has already emitted that value and no new values have been emitted from the source.
A latest
stream is meant to only be queried periodically, as mentioned by the docs.
Since each
will query a stream for values as fast as the stream can emit it, what you have is roughly
var lastSeen;
_("keyup", $("#searchbox"))
.debounce(1000)
.each(function (x) {
if (lastSeen == null) {
setTimeout(loop, 0);
}
lastSeen = x;
});
function loop() {
while (true) {
display(lookup(lastSeen));
}
}
You probably just want debounce
without latest
.
The part about having to use Array.prototype.slice
is annoying, but jQuery objects aren't arrays, so it's the expected behavior. You could do _($("article").toArray())
, which is slightly fewer characters.
I'm not sure if we should add support for array-like objects to the main stream constructor...we already do so much type coercion. Not to mention strings are array-like (in the sense that it has a length
and integer subscript operator), so adding support might interfere with the EventEmitter coercion.
We support Iterators right? In jQuery 3 $
returns an Iterator.
That's a good point. We do support both iterators and iterables.
Closing in favor of jQuery 3 accessibility and Iterator support alternative. Thanks everyone!
Eventstream Source, Debounced and Latest cracks your engine block.
Steps to reproduce
Once we get inside the map/each everything seams to be all fine and dandy, but upon the SECOND trigger, chrome just throws a fit, even closing the dang tab becomes a pane and rendering the issue nearly impossible to debug.
Another fun fact. having to write