setHostPromiseRejectionTracker method

void setHostPromiseRejectionTracker(
  1. JSHostPromiseRejectionTracker cb,
  2. Uint8List user_data
)

Implementation

void setHostPromiseRejectionTracker(
  JSHostPromiseRejectionTracker cb,
  Uint8List user_data,
) {
  _hostPromiseRejectionTrackerNC = NativeCallable.isolateLocal((
    Pointer<JSContext_> ctx,
    JSValue_ promise,
    JSValue_ reason,
    int is_handled,
    Pointer<Void> opaque,
  ) {
    final ctxw = JSContext(ctx);
    return cb(
      ctxw,
      JSValue.ptr(ctxw, promise),
      JSValue.ptr(ctxw, reason),
      is_handled,
      opaque.toUint8List(user_data.length),
    );
  });
  JS_SetHostPromiseRejectionTracker(
    _ref,
    _hostPromiseRejectionTrackerNC!.nativeFunction,
    user_data.toCAny(),
  );
}