isolate_agents 0.0.5 copy "isolate_agents: ^0.0.5" to clipboard
isolate_agents: ^0.0.5 copied to clipboard

Agents are state that lives on a background isolate.

Isolate Agents #

Description #

Isolate Agents adds a new class, Agent, which is a proper implementation of the Actor model for Dart. Where Isolates have no mechanism for communication, Agents do. It is inspired by Clojure's agents.

Example usage #

import 'package:isolate_agents/isolate_agents.dart';

void main() async {
  Agent<int> agent = await Agent.create(1);
  // The following add operation is executed in the Agent's isolate.
  agent.send((int x) => x + 1);
  assert(2 == await agent.exit());
}

Why? #

After writing Dart code for a couple of years I realized I was writing the same code over and over again in order to be able to use Isolates. Isolates don't fully implement the Actor model so a handshake of SendPort and a protocol needs to be devised for each non-trivial usage of Isolates. Agents factor all that logic into a reusable package, eliminating the SendPort handshake and standardizing the protocol.

70
likes
0
pub points
60%
popularity

Publisher

unverified uploader

Agents are state that lives on a background isolate.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on isolate_agents