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.

Libraries

e_observable
e_subscriber
edispatcher
i_observable