runSync<T> method

T runSync<T>(
  1. T computation()
)

Runs a synchronous computation in a new Zone carrying this context.

This is the preferred way to activate a context for synchronous code as it ensures that any asynchronous operations started within the computation will correctly inherit this context via the Zone mechanism.

Implementation

T runSync<T>(T Function() computation) {
  return runZoned(
    computation,
    zoneValues: {_zoneKey: this},
  );
}