plug 1.0.1 copy "plug: ^1.0.1" to clipboard
plug: ^1.0.1 copied to clipboard

A Dart/Flutter package to deal with async communication between 2 instances or methods

example/plug.dart

import 'package:plug/plug.dart';

main() {
  AsyncClass task = AsyncClass();
  task.onAsyncTaskIsCompleted.then(() => print('async task is completed!'));
  task.onAsyncValueTaked.take((value) => print('async value taked: $value'));

  task.asyncTask();
  task.asyncValue();
}

class AsyncClass {
  Plug onAsyncTaskIsCompleted = Plug();
  Plug<int> onAsyncValueTaked = Plug<int>();

  asyncTask() async {
    await Future.delayed(const Duration(seconds: 10));
    onAsyncTaskIsCompleted();
  }

  asyncValue() async {
    await Future.delayed(const Duration(seconds: 10));
    onAsyncValueTaked.send(10);
  }
}
1
likes
150
points
55
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart/Flutter package to deal with async communication between 2 instances or methods

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on plug