CreateTimerHandler typedef

CreateTimerHandler = Timer Function(Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f())

The type of a custom Zone.createTimer implementation function.

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 callback function f and duration are the ones which were passed to Zone.createTimer of zone (possibly through the Timer constructor).

The custom handler can choose to replace the function f with one that does something before, after or instead of calling f, and then call parent.createTimer(zone, replacement). or it can implement its own timer queue, which typically still depends on parent.createTimer to as a way to get started.

The function should return a Timer object which can be used to inspect and control the scheduled timer callback.

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

Implementation

typedef CreateTimerHandler =
    Timer Function(
      Zone self,
      ZoneDelegate parent,
      Zone zone,
      Duration duration,
      void Function() f,
    );