Dart package that conveniently wraps an isolate, ports and state for easy isolates.

Related tags

Templates agents
Overview

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.

You might also like...

Aplicativo de teste que roda em background timer atual utilizando Isolate.

# isolate_app A new Flutter project. ## Getting Started This project is a starting point for a Flutter application. A few resources to get you sta

Jun 20, 2022

This a library to simplify isolate thread communication.

This a library to simplify islate thread communication. It abstracts the data transfer between islate and the main thread into a simple channel, and t

Oct 31, 2022

State Persistence - Persist state across app launches. By default this library store state as a local JSON file called `data.json` in the applications data directory. Maintainer: @slightfoot

State Persistence Persist state across app launches. By default this library store state as a local JSON file called data.json in the applications dat

Sep 28, 2022

Minimalist and Easy State Management for Bloc Inspired from Dart Generics.

Velocity Bloc Getting started In the pubspec.yaml of your flutter project, add the following dependency: dependencies: ... velocity_bloc: latest_

Aug 1, 2023

An extension to the bloc state management library which lets you create State Machine using a declarative API

An extension to the bloc state management library which lets you create State Machine using a declarative API

Nov 28, 2022

A powerful state machine for MobX management, that can be used in almost any application state.

A powerful state machine for MobX management, which can be used in almost any application state. It has 3 states - loading, success, error - and is pe

Oct 31, 2022

Practice building basic animations in apps along with managing app state by BLoC State Management, Flutter Slider.

Practice building basic animations in apps along with managing app state by BLoC State Management including: Cubit & Animation Widget, Flutter Slider.

Jun 8, 2022

Nexus is a state management library that makes it easy to create and consume your application's reactive data to the user interface.

Nexus 🚀 Nexus is a state management library that makes it easy to create and consume your application's reactive data to the user interface. With nex

Sep 7, 2022
Comments
  • Questions about Isolate Groups and

    Questions about Isolate Groups and "move" operator

    (Context: I've learned a bit about parallelism in general and in Dart but don't have much hands-on experience)

    isolate_agents looks like an awesome implementation of the Actor pattern! Thanks for implementing and sharing it, especially the nice write up and example use-cases in your Medium post and this repo.

    I had a few thoughts / questions:

    • You mentioned that controlling the lifecycle of isolates is a benefit of isolate_agents compared to Flutter's .compute(). How do Agents relate to isolate groups? I remember hearing exciting stuff ~18 months ago about how much isolate groups would reduce the cost of spinning up new isolates. With Agents, would you create a pool of long-running agents and send work to them?

      • I don't even know enough about this to know what I'm asking, but it seems like there could be some interesting interactions between agents and isolate groups.
    • Another performance consideration you mentioned is the need for a "move" operator to allow constant time communication between isolates. Again I'm not familiar with how this all works, but I thought you might be interested in this Rust crate that generates FFI bindings and allows "zero copy returns over the FFI boundary". It would be awesome to use Dart everywhere (with agents?) instead of Rust for high-performance parallelism. Just thought I'd share in case that approach is of interest. (I love how you took inspiration from Clojure for isolate_agents)

    Thanks again!

    opened by KyleFin 1
  • 0.2.0

    0.2.0

    A response to feedback from @lrhn in https://github.com/gaaclarke/agents/commit/d3affbb75da5796da1da9ec06e832cc441d5eda2

    • Converted Agent.error to return an AgentError class.
    • Started handling errors in Agent.create.
    opened by gaaclarke 0
  • added error handling so an agent can be in an error state

    added error handling so an agent can be in an error state

    • Adds Agent.error and Agent.resetError.
    • Adds protection from talking to killed Agents.
    • Updated naming of methods based on feedback:
      • deref -> read
      • query -> eliminated for read
      • create -> eliminated for new create
      • createWithResult -> create
      • send -> update
    opened by gaaclarke 0
Owner
null
A Dart/Flutter package to perform network calls. It uses Isolates to perform network calls on Dart VM environments and WebWorkers on Web.

ArDriveHTTP ArDriveHTTP is a package to perform network calls for ArDrive Web. It uses Isolates to perform network calls on Dart VM environments and W

AR.IO 2 Dec 15, 2022
A Flutter package which allows you to work with MethodChannels in Isolate.

A Flutter package which allows you to work with MethodChannels in Isolate. Also it provides simplified multiplatform Isolate API.

Zemlaynikin Max 19 Jan 4, 2023
Isolate helper for flutter and dart.

Isolation Overview The package simplifies the creation and interaction between isolates. It encapsulates the entire boilerplate, leaving the developer

Plague Fox 15 Oct 29, 2022
Dart API Client which wraps the QvaPay API

qvapay_api_client Dart API Client which wraps the QvaPay API The client needs Dio to perform the requests, you must inject an instance in the construc

QvaPay 7 Nov 2, 2022
Ensdart - A dart library that wraps the Ethereum Name Service

⚡️ ENS Dart A dart library that wraps the Ethereum Name Service. The Ethereum Na

Chiziaruhoma Ogbonda 22 Nov 29, 2022
An isolated worker for Flutter (Isolate) and Web (Web Worker). Behaves almost the same as the compute function, except it is not a one-off worker.

A singleton isolated worker for all platforms. On most platforms, it uses Flutter's Isolate, except on the web, since Isolate is not available, it use

Iandi Santulus 30 Nov 11, 2022
An unofficial Flutter plugin that wraps pusher-websocket-java on Android and pusher-websocket-swift on iOS

Pusher Flutter Client An unofficial Flutter plugin that wraps pusher-websocket-java on Android and pusher-websocket-swift on iOS. Get it from pub. How

HomeX 31 Oct 21, 2022
Learn how to build a multi-step form flow and how to use bloc to effectively isolate the presentation layer from the business logic layer.

Multi-page Form Flow Learn how to build a multi-step form flow and how to use bloc to effectively isolate the presentation layer from the business log

Sandip Pramanik 15 Dec 19, 2022
Wraps Flutter shared_preferences plugin, providing a iOS Suite Name support, it's helpful for sharing data from App to Widget.

shared_preferences_ios_sn Wraps Flutter shared_preferences plugin and provides an iOS Suite Name support, it's helpful for sharing data from App to iO

null 3 Sep 14, 2022