allowInteropCaptureThis function

JSFunction allowInteropCaptureThis(Function f)

Returns a Function that when called from JavaScript captures its 'this' binding and calls f with the value of this passed as the first argument. When called from Dart, null will be passed as the first argument.

See the documentation for allowInterop. This method should only be used with package:js Dart-JavaScript interop.

Source

JSFunction allowInteropCaptureThis(Function f) {
  if (f is JSFunction) {
    // Behavior when the function is already a JS function is unspecified.
    throw new ArgumentError(
        "Function is already a JS function so cannot capture this.");
    return f;
  } else {
    var ret = _interopCaptureThisExpando[f];
    if (ret == null) {
      // TODO(jacobr): we could optimize this.
      ret = JSFunction._createWithThis(f);
      _interopCaptureThisExpando[f] = ret;
    }
    return ret;
  }
}

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