execute method

Future<T> execute(
  1. T context
)

start executing the hooks series by passing the context at the beginning

for each hook will pass the commit function to execute the next hook and the latest context changes by the hook before

to apply a context change use the commit function

Implementation

Future<T> execute(T context) async {
  T currentContext = context;

  for (var hook in _hooks) {
    final completer = Completer<T>();
    hook(currentContext, (T value) => completer.complete(value));
    currentContext = await completer.future;
  }

  return currentContext;
}