Skip to content
richardszalay edited this page May 20, 2011 · 2 revisions

Creates an Observable sequence from the event values of several events dispatched by an IEventDispatcher.

static function fromEvents(dispatcher : IEventDispatcher, eventNames : Array, 
    useCapture : Boolean = false, priority : int = 0) : IObservable

The useCapture and priority arguments will be used when adding an event listener to dispatcher.

Remarks

The event listener will be added when a subscription starts and removed if the subscription is cancelled.

The returned sequence does not complete

The returned sequence does not error

Marble Diagrams

event source 1  ──o───────────o──
                  │           │
event source 2  ──┼───o───o───┼──
                  │   │   │   │
output          ──o───o───o───o──

Return Value

IObservable.<Event>

Examples

Observable.fromEvents(stage, [MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_MOVE, MouseEvent.MOUSE_UP])
    .subscribe(function(event : MouseEvent) : void
    {
        trace("The mouse did something!");
    });
Clone this wiki locally