baconjs / bacon.js

Functional reactive programming library for TypeScript and JavaScript

Home Page:https://baconjs.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bacon.when doesn't respect the syncronization pattern, unless I subscribe to the source stream

eguneys opened this issue · comments

I have this stream by using Bacon.when

let esDrags = Bacon.when(
  [dDraw.esDrags, revents.drags, _ => _],
  [dStacks.drags, revents.drags, _ => ({
    stack: 'stack' + _.initial,
    ..._
  })],
  [revents.drags, _ => ({
    stack: 'event' + _.initial,
    ..._
  })]
);

//dStacks.drags.onValue();
esDrags.map(_ => _.stack).log();


// These streams are like:

revents.drags = Bacon.fromEvent(document, 'mousemove');
dStacks.drags = revents.drags.filter(whereDragIsInBounds);

The problem is esDrags emits two events that happen simultaneously one from dStacks.drags one from revents.drags.
The weird thing is if I uncomment the line dStacks.drags.onValue the problem dissapears and I see correct behaviour.

I couldn't reproduce the issue here: https://jsfiddle.net/bwgv97tn/
My project is at https://github.com/eguneys/tapper/tree/bacon