Forcing an event stream to finish

39 views
Skip to first unread message

Bennit

unread,
Jul 31, 2012, 9:36:05 AM7/31/12
to fla...@googlegroups.com
In the example below I draw a line on a canvas element, however, after the line is drawn, the event stream for mousemove still fires events. Is there a way to force event streams to stop receiving events?

Kind regards
Ben
----
    // mode -- Line
    function modeLine(startX,startY) {
        
        function drawLine(x1,y1,x2,y2) {
            context.beginPath();
            context.moveTo(x1,y1);
            context.lineTo(x2,y2);
            context.stroke();
            context.closePath();
        }
    
        var lineE = receiverE(); // once a line event will be fired
        var started = true; // the drawing of this line operation has started
        var pointA = new Point(startX,startY); // the starting point
        var pointB = pointA; // the current ending point
        
        jQCanvas.fj('extEvtE','mousemove').mapE(function(mm){
           if(started) {
               redraw();
               drawLine(startX,startY,mm.layerX,mm.layerY);
           }
           else { console.log('mouse move event after stop');}
        });
        
        jQCanvas.fj('extEvtE','mouseup').onceE().mapE(function(mu){
           started = false;
           lineE.sendEvent(new Line(mu.layerX,mu.layerY));
        });
        
        return lineE;
    }

Jay Shepherd

unread,
Jul 31, 2012, 6:08:30 PM7/31/12
to fla...@googlegroups.com

Hi Ben.  Checkout filterE,  ill give you a better example when im on a pc :-)

Alexander Yuryev

unread,
Oct 22, 2013, 5:46:58 AM10/22/13
to fla...@googlegroups.com
Do you mean .filterE(function(v){return started}) in this example? I don't understand how filterE will deal with events which continue to evaluate, but never used. I think it's a leak. (I have the same question at http://stackoverflow.com/questions/19513953/how-to-deal-with-flapjax-eventstreams-which-becomes-unused)

среда, 1 августа 2012 г., 2:08:30 UTC+4 пользователь Jay Shepherd написал:
Reply all
Reply to author
Forward
0 new messages