These are chat archives for pozadi/kefir

16th
Jul 2015
Ulric Wilfred
@shamansir
Jul 16 2015 03:06 UTC
What if I want a stream to shift an event to a next execution “cycle”? For example, if a stream is buffered with bufferWhileBy using it’s own values, I'd want the result stream to still fire the “buffering signal” as value, but then start buffering. An example:
Kefir.combine([ a, b ])
     .bufferWhileBy(Kefir.merge([
        a.map(x => true),
        b.map(x => false)
     ]), { flushOnChange: true }).log()
Here I want to still get an event from bin result stream before buffering will start.
I got this working:
Kefir.combine([ a, b ])
     .bufferWhileBy(Kefir.merge([
        a.map(x => true),
        b.map(x => false).flatMap(x => Kefir.later(1, x))
     ]), { flushOnChange: true }).log()
but I’m not sure it’s safe
Roman Pominov
@rpominov
Jul 16 2015 06:29 UTC
well this indeed problematic. We don't currently have api for that neither internal nor external. It may start to "just work" if we do rpominov/kefir#120 , but probably wont work in all cases anyway.
The fix you have is not quite safe, I think it will work only if events in the stream won't come in synchronous groups.
Btw, instead of s.flatMap(x => Kefir.later(1, x)) you can do s.delay(1), or actually s.delay(0) is even better.