EventDispatcher mixin
JavaScript events for custom objects.
// Adding events to a custom object
class Car with EventDispatcher {
start() {
this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
}
}
// Using events with the custom object
final car = Car();
car.addEventListener(
'start',
(event){
alert( event.message );
}
);
car.start();
- Mixin applications
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addEventListener(
String type, Function listener) → void -
type
- The type of event to listen to. -
clearListeners(
) → void - Remove all Listeners.
-
dispatchEvent(
Event event) → void -
event
- The event that gets fired. -
hasEventListener(
String type, Function listener) → bool -
type
- The type of event to listen to. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeEventListener(
String type, Function listener) → void - type - The type of the listener that gets removed.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited