These are chat archives for pozadi/kefir

17th
Feb 2015
Ulric Wilfred
@shamansir
Feb 17 2015 00:04
If I change the example numbers-stream to some generator-like function, like next() and nothing else, and call this function from inside the zip streams, may this help?
Roman Pominov
@rpominov
Feb 17 2015 00:22
@shamansir i don't quite understand why you use repeat if you always return same stream from generator function.
it's doesn't supposed to be used like this
you should return a new stream on each iteration
in you last example it hangs because it gets to the situation when generator constantly returns ended stream :)
Roman Pominov
@rpominov
Feb 17 2015 00:34
btw, you can pass arrays to .zip instead of observables
but there should be at least one actual observable, otherwise you don't need frp)
so you can .zip an observable with an array
Ulric Wilfred
@shamansir
Feb 17 2015 07:29
...if you always return the same stream
that's what I missed there, thank you!
The number-generator is just an example, I want these numbers to be generated in time like events later, but they also should have the ability to be completely synchronous.
Ulric Wilfred
@shamansir
Feb 17 2015 07:37
repeat is really a dangerous guy, it's hard to find the reasons if you missed them :)
Ulric Wilfred
@shamansir
Feb 17 2015 07:46
"to debug the reasons", I mean
Ulric Wilfred
@shamansir
Feb 17 2015 08:39
btw, I think, yeah, it's an obvious kind of thing, but it could be added to documentation anyway, as a notice. Somewhere among the 18+ and M for Mature badges marking this method :)
Ulric Wilfred
@shamansir
Feb 17 2015 08:58
…and anyway it hangs :worried: http://jsfiddle.net/shaman_sir/2q0aqg94/
Roman Pominov
@rpominov
Feb 17 2015 09:32
the problem is, it never subscribes to second repeat stream
when zip subscribes to first one it gets to infinite loop, since the exit condition is never true (because it doesn't even get chance to subscribe to second stream and make finished['two'] = true)
it just doesn't work well with synchronous observables, it works sort of correct but the logic of that correctness is pretty tricky
Roman Pominov
@rpominov
Feb 17 2015 09:39
but what are you trying to do? maybe you don't need repeat anyway? :)
i.e. what is your input streams, and what result streams you want to build of them?
Roman Pominov
@rpominov
Feb 17 2015 09:44
var a = false, b = false;
while (a === false || b === false) {
  a = true;
}
while (a === false || b === false) {
  b = true;
}
— that's how your example currently works in a nutshell
Ulric Wilfred
@shamansir
Feb 17 2015 09:49

Could be so :). I want to be able to arrange several streams of values in one “flow” which ends only when the last one was finished:

1-2-3-4-1-2-3-4-1-2——   // iterNums 4
1-2-3-4-5-6-7-8-9-10X      // iterNums 10
1-2-3-1-2-3-1-2-3-1------   // iterNums 3

Result stream:

[1,1,1], [2,2,2], [3,3,3], [4,4,1], [1,5,2][2,10,1] X
this pauses between values may appear longer and they could not match in time, of course, then it expected to work like zip
Yeah, I supposed the first one stream hangs even for previous examples.
Ulric Wilfred
@shamansir
Feb 17 2015 09:56
may be it’s too crazy, yeah, I plan to try to emit next values from the merging operation so it could control taking next values from inside and prevent blocking this way, like iterators do. If this won’t work, I give up :)
Roman Pominov
@rpominov
Feb 17 2015 09:57
http://jsfiddle.net/2q0aqg94/1/ — here, fixed it (i think)
made your sync streams to emit end asynchronously, so zip can subscribe to second stream
Ulric Wilfred
@shamansir
Feb 17 2015 10:02
hmm, yeah, it works as expected! :) [so seems I cannot make this synchro in special cases]. Thank you!