then method

JSPromise then([
  1. Function? onFulfilled,
  2. Function? onRejected
])

Implementation

JSPromise then([Function? onFulfilled, Function? onRejected]) {
  return JSPromise((List funcs) {
    final resolve = funcs[0];
    final reject = funcs[1];
    final h = _PromiseHandler(onFulfilled, onRejected, resolve, reject);
    _handlers.add(h);
    if (_state != _PromiseState.pending) {
      scheduleMicrotask(_runHandlers);
    }
  });
}