eventable 5.2.1

  • README.md
  • Installing
  • Versions
  • 65

#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:

##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){
      runaway();
    }else{
      print('cat not disturbed');
    }
  }

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

}

class Bark{
  final int volume;
  Bark(this.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

}

##Omni

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

##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);


##DuplicateEventSettingError

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.

##EmitTimeQueueChangeError

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:


dependencies:
  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...

Analysis

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

  • Dart: 2.0.0-dev.54.0
  • pana: 0.11.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
72 / 100
Health:
Code health derived from static analysis. [more]
96 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]
65
Learn more about scoring.

Platforms

Detected platforms: web, other

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

Suggestions

  • Maintain CHANGELOG.md.

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

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 6 hints.

    Run dartfmt to format lib/duplicate_event_setting_error.dart.

    Run dartfmt to format lib/emit_time_queue_change_error.dart.

    Similar analysis of the following files failed:

    • lib/event.dart (hint)
    • lib/event_detector.dart (hint)
    • lib/event_emitter.dart (hint)
    • lib/eventable.dart (hint)

Dependencies

Package Constraint Resolved Available
Dev dependencies
unittest any