wrapMiddlewareNextCall<T> function

Future<bool> wrapMiddlewareNextCall<T>(
  1. T context,
  2. Middleware<T> middleware
)

Implementation

Future<bool> wrapMiddlewareNextCall<T>(
  T context,
  Middleware<T> middleware,
) async {
  var called = false;

  await middleware(context, () {
    if (called) {
      throw Exception('next() called multiple times');
    }

    called = true;
  });

  return called;
}