wrap<T> static method

T wrap<T>(
  1. HookContext context,
  2. T callback()
)

Runs callback with context as the current HookContext.

This method should only be used by HookContext implementations.

Implementation

static T wrap<T>(HookContext context, T Function() callback) {
  _stack.add(context);
  try {
    return callback();
  } finally {
    _stack.removeLast();
  }
}