isolated_object 0.1.0 copy "isolated_object: ^0.1.0" to clipboard
isolated_object: ^0.1.0 copied to clipboard

Wraps an object in a dedicated isolate and forwards method calls to it, so timer- or event-loop-driven work (e.g. progress spinners) keeps running even when the calling isolate's event loop is blocked [...]

isolated_object #

Wraps an object in a dedicated isolate and forwards method calls to it, so timer- or event-loop-driven work (e.g. progress spinners) keeps animating even when the calling isolate's event loop is blocked by heavy synchronous work.

Dependency-free.

Usage #

import 'package:isolated_object/isolated_object.dart';

final counter = IsolatedObject<Counter>(() => Counter());

await counter.evaluate((c) => c.increment());
final value = await counter.evaluate((c) => c.value);

await counter.close();

The factory runs inside the child isolate; each evaluate forwards a closure to that isolate and returns the result. close() shuts the isolate down, failing any in-flight calls rather than letting them hang.

0
likes
140
points
17
downloads

Documentation

API reference

Publisher

verified publisherserverpod.dev

Weekly Downloads

Wraps an object in a dedicated isolate and forwards method calls to it, so timer- or event-loop-driven work (e.g. progress spinners) keeps running even when the calling isolate's event loop is blocked. Dependency-free.

License

BSD-3-Clause (license)

More

Packages that depend on isolated_object