Zone class

A Zone represents the asynchronous version of a dynamic extent. Asynchronous callbacks are executed in the zone they have been queued in. For example, the callback of a future.then is executed in the same zone as the one where the then was invoked.

A Zone represents the asynchronous version of a dynamic extent. Asynchronous callbacks are executed in the zone they have been queued in. For example, the callback of a future.then is executed in the same zone as the one where the then was invoked.

Constants

ROOT = _ROOT_ZONE
The root zone that is implicitly created.

Static Properties

current Zone
read-only

Instance Properties

parent Zone
read-only
errorZone Zone
read-only

Instance Methods

handleUncaughtError(error, StackTrace stackTrace) → dynamic
inSameErrorZone(Zone otherZone) → bool
Returns true if this and otherZone are in the same error zone.
fork({ZoneSpecification specification, Map zoneValues}) → Zone
Creates a new zone as a child of this.
run(dynamic f()) → dynamic
Executes the given function f in this zone.
runUnary(dynamic f(arg), arg) → dynamic
Executes the given callback f with argument arg in this zone.
runBinary(dynamic f(arg1, arg2), arg1, arg2) → dynamic
Executes the given callback f with argument arg1 and arg2 in this zone.
runGuarded(dynamic f()) → dynamic
Executes the given function f in this zone.
runUnaryGuarded(dynamic f(arg), arg) → dynamic
Executes the given callback f in this zone.
runBinaryGuarded(dynamic f(arg1, arg2), arg1, arg2) → dynamic
Executes the given callback f in this zone.
registerCallback(dynamic callback()) → ZoneCallback
Registers the given callback in this zone.
registerUnaryCallback(dynamic callback(arg)) → ZoneUnaryCallback
Registers the given callback in this zone.
registerBinaryCallback(dynamic callback(arg1, arg2)) → ZoneBinaryCallback
Registers the given callback in this zone.
bindCallback(dynamic f(), {bool runGuarded: true}) → ZoneCallback
Equivalent to:
bindUnaryCallback(dynamic f(arg), {bool runGuarded: true}) → ZoneUnaryCallback
Equivalent to:
bindBinaryCallback(dynamic f(arg1, arg2), {bool runGuarded: true}) → ZoneBinaryCallback
Equivalent to:
errorCallback(Object error, StackTrace stackTrace) → AsyncError
Intercepts errors when added programmtically to a Future or Stream.
scheduleMicrotask(void f()) → void
Runs f asynchronously in this zone.
createTimer(Duration duration, void callback()) → Timer
Creates a Timer where the callback is executed in this zone.
createPeriodicTimer(Duration period, void callback(Timer timer)) → Timer
Creates a periodic Timer where the callback is executed in this zone.
print(String line) → void
Prints the given line.

Operators

operator [](Object key) → dynamic
Retrieves the zone-value associated with key.