forTarget method

Stream<T> forTarget(EventTarget e, { bool useCapture: false })

Gets a Stream for this event type, on the specified target.

This will always return a broadcast stream so multiple listeners can be used simultaneously.

This may be used to capture DOM events:

Element.keyDownEvent.forTarget(element, useCapture: true).listen(...);

// Alternate method:
Element.keyDownEvent.forTarget(element).capture(...);

Or for listening to an event which will bubble through the DOM tree:

MediaElement.pauseEvent.forTarget(document.body).listen(...);

See also:

addEventListener

Source

Stream<T> forTarget(EventTarget e, {bool useCapture: false}) =>
    new _EventStream<T>(e, _eventType, useCapture);

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-html/EventStreamProvider/forTarget.html