W3cubDocs

/Dart 2

forElement method

ElementStream<T> forElement (Element e, { bool useCapture: false })

Gets an ElementEventStream for this event type, on the specified element.

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

This may be used to capture DOM events:

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

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

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

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

See also:

addEventListener

Implementation

ElementStream<T> forElement(Element e, {bool useCapture: false}) {
  return new _ElementEventStreamImpl<T>(e, _eventType, useCapture);
}

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