handleFutureWithMapper<T, S> function

PromiseJsImpl<S> handleFutureWithMapper<T, S>(
  1. Future<T> future,
  2. Func1<T, S> mapper
)

Handles the Future object with the provided mapper function.

Implementation

PromiseJsImpl<S> handleFutureWithMapper<T, S>(
  Future<T> future,
  Func1<T, S> mapper,
) {
  return PromiseJsImpl<S>(allowInterop((
    Function(S) resolve,
    Function(Object) reject,
  ) {
    future.then((value) {
      var mappedValue = mapper(value);
      resolve(mappedValue);
    }).catchError((error) => reject(error));
  }));
}