eventable 5.2.1

  • README.md
  • Installing
  • Versions
  • 42

#Eventable Build Status

Eventable provides 2 mixins to make your classes eventable, EventEmitter and EventDetector. Simply use these mixins to make your types either emit, detect or do both for asynchronous events. An Event can carry any data object, to listen for an Event carrying a particular data type just listen for that data type. Usage is best described with a simple example:


class Dog extends Object with EventEmitter{

  void bark(int volume){
    emitEvent(new Bark(volume));

class Cat extends Object with EventDetector{

  void dogBarkHandler(Event<Bark> event){
    var bark = event.data;
    if(bark.volume > 10){
      print('cat not disturbed');

  void runaway(){
    print('cat running away');


class Bark{
  final int volume;

void main(){

  var dog = new Dog();
  var cat = new Cat();

  cat.listen(dog, Bark, cat.dogBarkHandler);

  dog.bark(9);  // cat not disturbed
  dog.bark(11); // cat runs away



There is a special event data type Omni which allows detectors to listen to every event emitted by an EventEmitter with a single EventAction.


A typedef is specified in the eventable library which serves as the function signature accepted as the last argument to an EventDetectors

typedef void EventAction(Event event);


A given **EventDetector** can only listen to a specific event-data-type from a specific
**EventEmitter** once, therefore it is an error to try to attach more **EventActions**
to the same **EventEmitter** / event-data-type combination. If a second attempt is made
by an **EventDetector** to listen to the same **EventEmitter** / event-data-type combination
a **DuplicateEventSettingError** will be thrown.


It is not permitted to add or remove **EventActions** whilst the event is being
emitted, meaning you may not attach an **EventAction** to an event which adds or
removes **EventActions** from that same event-data-type queue, if such an attempt is made a 
**EmitTimeQueueChangeError** will be thrown. to remove **EventActions** for an emitting **Event**
it is best to do so in the **finished** **Future** property on the **Event** object.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  eventable: ^5.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:eventable/eventable.dart';
Version Uploaded Documentation Archive
5.2.1 Oct 26, 2014 Go to the documentation of eventable 5.2.1 Download eventable 5.2.1 archive
5.2.0 Oct 26, 2014 Go to the documentation of eventable 5.2.0 Download eventable 5.2.0 archive
5.1.1 Jun 1, 2014 Go to the documentation of eventable 5.1.1 Download eventable 5.1.1 archive
5.1.0 May 26, 2014 Go to the documentation of eventable 5.1.0 Download eventable 5.1.0 archive
5.0.0 May 19, 2014 Go to the documentation of eventable 5.0.0 Download eventable 5.0.0 archive
4.0.5 May 16, 2014 Go to the documentation of eventable 4.0.5 Download eventable 4.0.5 archive
4.0.4 May 16, 2014 Go to the documentation of eventable 4.0.4 Download eventable 4.0.4 archive
3.0.4 May 14, 2014 Go to the documentation of eventable 3.0.4 Download eventable 3.0.4 archive
3.0.3 May 10, 2014 Go to the documentation of eventable 3.0.3 Download eventable 3.0.3 archive
3.0.2 Apr 29, 2014 Go to the documentation of eventable 3.0.2 Download eventable 3.0.2 archive

All 27 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Sep 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3


Detected platforms: web, other

Primary library: package:eventable/eventable.dart with components: mirrors.

Issues and suggestions

Package is too old.

The package was released more than two years ago.

Maintain CHANGELOG.md.

Changelog entries help clients to follow the progress in your code.

Add SDK constraint in pubspec.yaml.

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

Format lib/duplicate_event_setting_error.dart.

Run dartfmt to format lib/duplicate_event_setting_error.dart.

Format lib/emit_time_queue_change_error.dart.

Run dartfmt to format lib/emit_time_queue_change_error.dart.

Format lib/event.dart.

Run dartfmt to format lib/event.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/event_detector.dart (Run dartfmt to format lib/event_detector.dart.)
  • lib/event_emitter.dart (Run dartfmt to format lib/event_emitter.dart.)
  • lib/eventable.dart (1 hint)


Package Constraint Resolved Available
Dev dependencies
unittest any