addRules method

Future<List<Rule>> addRules(
  1. String eventName,
  2. int webViewInstanceId,
  3. List<Rule> rules
)

Registers rules to handle events. eventName Name of the event this function affects. webViewInstanceId If provided, this is an integer that uniquely identfies the

Implementation

Future<List<Rule>> addRules(
  String eventName,
  int webViewInstanceId,
  List<Rule> rules,
) {
  var $completer = Completer<List<Rule>>();
  _wrapped.addRules(
    eventName,
    webViewInstanceId,
    rules.toJSArray((e) => e.toJS),
    (JSArray rules) {
      if (checkRuntimeLastError($completer)) {
        $completer.complete(rules.toDart
            .cast<$js.Rule>()
            .map((e) => Rule.fromJS(e))
            .toList());
      }
    }.toJS,
  );
  return $completer.future;
}