-
Notifications
You must be signed in to change notification settings - Fork 3k
Possible bug: can no longer merge and takeUntil on the same stream #1360
Copy link
Copy link
Closed
Description
In RxJS 4 the code below would print 'up' and return to 0, 0 upon releasing the mouse from a drag. In RxJS 5 this is no longer happens.
var box = document.getElementById('box');
var mouseDown = Rx.Observable.fromEvent(document, 'mousedown');
var mouseUp = Rx.Observable.fromEvent(document, 'mouseup');
var mouseMove = Rx.Observable.fromEvent(document, 'mousemove');
var mouseDrag = mouseDown.flatMap(function(md){
var startX = md.offsetX;
var startY = md.offsetY;
return mouseMove
.merge(mouseUp.map(x => 'up')) // <----
.map(function(mm){
if (mm === 'up') {
console.log('up'); // to show it's no longer hit
return {
left: 0,
top: 0
};
}
return {
left: mm.clientX - startX,
top: mm.clientY - startY
};
}).takeUntil(mouseUp); // <----
});
mouseDrag.subscribe(function(e){
box.style.top = e.top + 'px';
box.style.left = e.left + 'px';
});RxJS 4 jsbin: https://jsbin.com/cigirovohe/1/edit?html,js,console,output
RxJS 5 jsbin: https://jsbin.com/metosonayi/1/edit?html,js,console,output
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels