function method

JsValue function(
  1. dynamic func(
    1. List argv
    )
)
override

Send a dart callback to JS context.

Implementation

JsValue function(Function(List argv) func) {
  return _action(JS_ACTION_WRAP_FUNCTION, 0, block: (results, len) {
    if (len == 1 && results[0].type == ARG_TYPE_RAW_POINTER) {
      Pointer rawPtr = results[0].ptrValue;
      _instances[rawPtr] = func;
      var ptr = binder.retainValue(_context, rawPtr);
      return IOJsValue._instance(this, ptr.ref.ptrValue, func);
    } else {
      throw Exception("Wrong result");
    }
  });
}