Skip to content

RunHandler

typedef RunHandler = R Function(
  Zone self,
  ZoneDelegate parent,
  Zone zone,
  R Function() f,
)

The type of a custom Zone.run implementation function.

A function used as ZoneSpecification.run to specialize the behavior of a new zone.

Receives the Zone that the handler was registered on as self, a delegate forwarding to the handlers of self's parent zone as parent, and the current zone where the error was uncaught as zone, which will have self as a parent zone.

The function f is the function which was passed to the Zone.run of zone.

The default behavior of Zone.run is to call f in the current zone, zone. A custom handler can do things before, after or instead of calling f.

The function must only access zone-related functionality through self, parent or zone. It should not depend on the current zone (Zone.current).