Agent<T> class

State that lives on an isolate.

This is a convenient wrapper around having an isolate, dart ports and managing some state that is edited on the isolate.

Properties

error Future<AgentError?>
Gets the current error associated with the Agent, null if there is none.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

exit() Future<T>
Kills the agent and returns its state value. This is faster than calling deref then kill since Dart will elide the copy of the result.
kill() → void
Kills the Agent's isolate. Any interaction with the Agent after this will result in a StateError.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read<U>({U query(T state)?}) Future<U>
Reads the Agent's state with a closure.
resetError() Future<void>
Resets the Agent so it can start receiving messages again.
toString() String
A string representation of this object.
inherited
update(T func(T)) Future<void>
Send a closure func that will be executed in the Agent's Isolate. The result of func is assigned to the value of the Agent.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

create<T>(T func()) Future<Agent<T>>
Creates the Agent whose initial state is the result of executing func.