getConcurrencyMiddleware<T> function
Concurrently launches middleware,
the chain will continue if next()
is called in all middlewares
Warning: Error interrupts all others
Example:
getConcurrencyMiddleware(
initializeUser,
initializeSession,
initializeDatabase
);
Implementation
// ignore: prefer_expression_function_bodies
Middleware<T> getConcurrencyMiddleware<T>(Iterable<Middleware<T>> middlewares) {
return (context, next) async {
await Future.wait(
// ignore: prefer_expression_function_bodies
List<Middleware<T>>.from(middlewares).map((middleware) {
return wrapMiddlewareNextCall(context, middleware);
}),
);
return next();
};
}