loner 3.0.1 copy "loner: ^3.0.1" to clipboard
loner: ^3.0.1 copied to clipboard

discontinued
SDKDart

This library contains types that allow for executing code in a spawned isolate, perhaps with additional imports.

loner #

This library contains types that allow for executing code in a spawned isolate, perhaps with additional imports.

Subclass Executable and override its execute method. Invoke Loner.executeWithType, passing in that subclass. The code in execute will run in another isolate. Any value it returns will be returned by Loner.executeWithType.

A returned value must be a primitive type (anything that is encodable as JSON). You may pass parameters to the other isolate by providing a message map.

Example:

class Echo extends Executable {
  Echo(Map<String, dynamic> message)
      : echoMessage = message['echo'],
        super(message);

  final String echoMessage;

  @override
  Future<dynamic> execute() async {
    return echoMessage;
  }
}

Future main() async {
    final result = await Loner.executeWithType(Echo, message: {'echo': 'hello'});
    assert(result == 'hello');
}
0
likes
80
pub points
4%
popularity

Publisher

verified publisheraldrinsartfactory.com

This library contains types that allow for executing code in a spawned isolate, perhaps with additional imports.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (LICENSE)

Dependencies

analyzer

More

Packages that depend on loner