question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add bufferWithTimeout() and bufferWithInterval().

See original GitHub issue

Highland uses setTimeout() and Kefir uses setInterval() for the batch/buffer with time (illustrated below). It would be nice to have both functions in Kefir, with a distinctive name.

Using highlandStream.batchWithTimeOrCount(100 /*ms/*, Infinity):

[ 0, 0, 0 ]
[ 150, 200, 250 ]
[ 300, 350, 400 ]

Using kefirStream.bufferWithTimeOrCount(100 /*ms*/, Infinity):

[ 0, 0, 0 ]
[ 150 ]
[ 200, 250 ]
[ 300, 350 ]
[ 400 ]

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rpominovcommented, Nov 15, 2016

Yeah, if we subscribe to the same stream twice here is how it can be done:

var stream = Kefir.stream(em => {
  setTimeout(() => {em.value(0); em.value(0); em.value(0)}, 0)
  setTimeout(() => {em.value(150)}, 150)
  setTimeout(() => {em.value(200)}, 200)
  setTimeout(() => {em.value(250)}, 250)
  setTimeout(() => {em.value(300)}, 300)
  setTimeout(() => {em.value(350)}, 350)
  setTimeout(() => {em.value(400); em.end()}, 400)
})

stream.bufferBy(stream.flatMapFirst(() => Kefir.later(100))).log()
0reactions
rpominovcommented, Nov 15, 2016

Yea, I just not 100% sure about Flow/TypeScript, but I’ll merge the PR if you create one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · kefirjs/kefir - GitHub
Add documentation to "Kefir.pool" as "Rx.Subject equivalent". #306 opened on Jul 31, ... Add bufferWithTimeout() and bufferWithInterval(). enhancement.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found