execute method
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;
}