edispatcher 1.0.2 copy "edispatcher: ^1.0.2" to clipboard
edispatcher: ^1.0.2 copied to clipboard

A tool class that is convenient for developers to implement event distribution

edispatcher #

event dispatcher

Getting Started #

//event define
abstract class IRandomEvent {}
class RandomNotifyEvent implements IRandomEvent {
  final String random;
  RandomNotifyEvent(this.random);
}

//IRandomEvent event observable
class RandomModel extends EObservable<IRandomEvent> {
  void random() {
    final r = Random().nextInt(0x7FFFFFFF).toString();
    dispatch(RandomNotifyEvent(r));
  }
}

//event subscriber
subscribe<RandomNotifyEvent>(_random, (event) {
      //event dispatched, refresh ui
      setState(() {
        _randomText = event.random;
      });
    });
}

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

2
likes
40
pub points
0%
popularity

Publisher

verified publisheradeveloper.tech

A tool class that is convenient for developers to implement event distribution

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on edispatcher