Dart Documentationchrome.eventsChromeEvent

ChromeEvent class

An object which allows the addition and removal of listeners for a Chrome event.

class ChromeEvent extends ChromeObject {
 ChromeEvent();
 ChromeEvent.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);

 /**
  * Registers an event listener _callback_ to an event.
  */
 Future addListener() {
   var completer = new ChromeCompleter.noArgs();
   jsProxy.callMethod('addListener', [completer.callback]);
   return completer.future;
 }

 /**
  * Deregisters an event listener _callback_ from an event.
  */
 Future removeListener() {
   var completer = new ChromeCompleter.noArgs();
   jsProxy.callMethod('removeListener', [completer.callback]);
   return completer.future;
 }

 bool hasListener(dynamic callback) {
   return jsProxy.callMethod('hasListener', [jsify(callback)]);
 }

 bool hasListeners() {
   return jsProxy.callMethod('hasListeners');
 }

 /**
  * Registers rules to handle events.
  * 
  * [eventName] Name of the event this function affects.
  * 
  * [rules] Rules to be registered. These do not replace previously registered
  * rules.
  * 
  * Returns:
  * Rules that were registered, the optional parameters are filled with values.
  */
 Future<List<Rule>> addRules(String eventName, List<Rule> rules) {
   var completer = new ChromeCompleter<List<Rule>>.oneArg((e) => listify(e, _createRule));
   jsProxy.callMethod('addRules', [eventName, jsify(rules), completer.callback]);
   return completer.future;
 }

 /**
  * Returns currently registered rules.
  * 
  * [eventName] Name of the event this function affects.
  * 
  * [ruleIdentifiers] If an array is passed, only rules with identifiers
  * contained in this array are returned.
  * 
  * Returns:
  * Rules that were registered, the optional parameters are filled with values.
  */
 Future<List<Rule>> getRules(String eventName, [List<String> ruleIdentifiers]) {
   var completer = new ChromeCompleter<List<Rule>>.oneArg((e) => listify(e, _createRule));
   jsProxy.callMethod('getRules', [eventName, jsify(ruleIdentifiers), completer.callback]);
   return completer.future;
 }

 /**
  * Unregisters currently registered rules.
  * 
  * [eventName] Name of the event this function affects.
  * 
  * [ruleIdentifiers] If an array is passed, only rules with identifiers
  * contained in this array are unregistered.
  */
 Future removeRules(String eventName, [List<String> ruleIdentifiers]) {
   var completer = new ChromeCompleter.noArgs();
   jsProxy.callMethod('removeRules', [eventName, jsify(ruleIdentifiers), completer.callback]);
   return completer.future;
 }
}

Extends

ChromeObject > ChromeEvent

Constructors

new ChromeEvent() #

Create a new instance of a ChromeObject, which creates and delegates to a JsObject proxy.

docs inherited from ChromeObject
ChromeEvent();

new ChromeEvent.fromProxy(JsObject jsProxy) #

Create a new instance of a ChromeObject, which delegates to the given JsObject proxy.

docs inherited from ChromeObject
ChromeEvent.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);

Properties

final jsProxy #

inherited from ChromeObject
final dynamic jsProxy

Methods

Future addListener() #

Registers an event listener callback to an event.

Future addListener() {
 var completer = new ChromeCompleter.noArgs();
 jsProxy.callMethod('addListener', [completer.callback]);
 return completer.future;
}

Future<List<Rule>> addRules(String eventName, List<Rule> rules) #

Registers rules to handle events.

eventName Name of the event this function affects.

rules Rules to be registered. These do not replace previously registered rules.

Returns: Rules that were registered, the optional parameters are filled with values.

Future<List<Rule>> addRules(String eventName, List<Rule> rules) {
 var completer = new ChromeCompleter<List<Rule>>.oneArg((e) => listify(e, _createRule));
 jsProxy.callMethod('addRules', [eventName, jsify(rules), completer.callback]);
 return completer.future;
}

Future<List<Rule>> getRules(String eventName, [List<String> ruleIdentifiers]) #

Returns currently registered rules.

eventName Name of the event this function affects.

ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are returned.

Returns: Rules that were registered, the optional parameters are filled with values.

Future<List<Rule>> getRules(String eventName, [List<String> ruleIdentifiers]) {
 var completer = new ChromeCompleter<List<Rule>>.oneArg((e) => listify(e, _createRule));
 jsProxy.callMethod('getRules', [eventName, jsify(ruleIdentifiers), completer.callback]);
 return completer.future;
}

bool hasListener(callback) #

bool hasListener(dynamic callback) {
 return jsProxy.callMethod('hasListener', [jsify(callback)]);
}

bool hasListeners() #

bool hasListeners() {
 return jsProxy.callMethod('hasListeners');
}

Future removeListener() #

Deregisters an event listener callback from an event.

Future removeListener() {
 var completer = new ChromeCompleter.noArgs();
 jsProxy.callMethod('removeListener', [completer.callback]);
 return completer.future;
}

Future removeRules(String eventName, [List<String> ruleIdentifiers]) #

Unregisters currently registered rules.

eventName Name of the event this function affects.

ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are unregistered.

Future removeRules(String eventName, [List<String> ruleIdentifiers]) {
 var completer = new ChromeCompleter.noArgs();
 jsProxy.callMethod('removeRules', [eventName, jsify(ruleIdentifiers), completer.callback]);
 return completer.future;
}

JsObject toJs() #

inherited from ChromeObject
JsObject toJs() => jsProxy;

String toString() #

inherited from ChromeObject

Returns a string representation of this object.

docs inherited from Object
String toString() => jsProxy.toString();