PackageTrack
Sign in Get early access

event

Create lightweight custom Events, that allow interested subscribers to be notified that something has happened.

3.1.0 17K downloads/mo #2354 most downloaded on pub.dev aryehof/dart-event

What this package is like to depend on

Last release 2 years ago

no release in 18 months

Ships unpredictably

gaps range from 8 days to 2.6 years

Nearly every release is documented

notes for 19 of 21 stable releases

Nothing withdrawn

no release was ever pulled

7 years old

21 releases · first in 2020

0 releases in the last 12 months

see the full history below

Release timeline

21 releases · Jan 2020 to Sep 2024
2021 2022 2023 2024 2025 2026
Release Pre-release

Releases

latest 21
  1. 3.1.0 10 Sep 2024
    Release notes
    1. Minor internal changes
    2. Diagnostic logging is available. See the new Diagnostics section in README.md and the example application for further information.
    3. Both the subscribe() and broadcast() Event methods produce diagnostic messages at Severity debug. To output these messages use the showLog() method with Severity debug. See the example application.
    // Example diagnostics logging output
    Event (debug): 2024-09-10 11:37:49.665124Z Subscribed to Event "countChanged:Event<EventArgs>"
    Event (debug): 2024-09-10 11:37:49.675925Z Broadcast Event "countChanged:Event<EventArgs>"
    
    Open source →
    Release notes
    • Minor internal changes

    • Diagnostic logging is available. See the new Diagnostics section in README.md and the example application for further information.

    • Both the subscribe() and broadcast() Event methods produce diagnostic messages at Severity debug . To output these messages use the showLog() method with Severity debug . See the example application.

    // Example diagnostics logging output Event (debug): 2024-09-10 11:37:49.665124Z Subscribed to Event "countChanged:Event<EventArgs>" Event (debug): 2024-09-10 11:37:49.675925Z Broadcast Event "countChanged:Event<EventArgs>"

    Open source →
  2. 3.0.1 07 Aug 2024

    Nothing published for this version

  3. 3.0.0 07 Aug 2024
    Release notes

    This version has BREAKING CHANGES

    1. Minimum Dart sdk dependency is now 3.4.0
    2. An EventArgs instance is created and broadcast automatically if none provided, i.e.
      var e = Event();
        // is equivalent to...
      var e = Event<EventArgs>(); 
    
    1. An Event can have a name specified. Some code might be subscribed to more than one Event, so this lets one know which Event caused the code to run.
      var e = Event("CountUpdatedEvent");
      e.subscribe((args) => print(args.eventName));
      // outputs "null" until the event is broadcast.
      e.broadcast();
      // outputs "CountUpdatedEvent"
    
    1. EventArgs includes two accessible values:- eventName and whenOccurred. Both have a default value of null, and are only populated when the Event is broadcast.
      // Example without Event name
      var e = Event();
      e.subscribe((args) {
        print(args.eventName); // outputs null
        print(args.whenOccurred); // outputs time of broadcast
      };
      e.broadcast();
      
      // Example specifying an Event name
      var e = Event("myEvent");
      e.subscribe((args) {
        print(args.eventName); // outputs "myEvent"
        print(args.whenOccurred); // outputs time of broadcast
      };
      e.broadcast();
    
    1. The WhenWhy EventArg derived class is DEPRECATED and removed. Use the EventArgs whenOccurred property instead.
    2. The + and - equivalents to subscribe() and unsubscribe() have been DEPRECATED and removed for simplicity.
    3. A custom ArgsError is thrown if an Event is broadcast() without an appropriate argument
      var e = Event<CustomEventArgs>();
      // following throws an ArgsError because broadcast()
      // specifies no CustomEventArgs
      e.broadcast();
      // In this case, the ArgsError message shown would be...
      // "Incorrect args being broadcast - args should be a CustomEventArgs"
      
      // instead, following is correct
      e.broadcast(CustomEventArgs("hello"));
    
    1. A new property genericType has been added to the Event class. Gets the generic type of the Event, e.g.
      var e = Event<Value<int>>();
      assert(e.genericType == Value<int>); 
    
    1. The broadcast() method now returns a bool, indicating if the broadcast had subscribers or not. No subscribers means the broadcast() method is effectively ignored.
      var e = Event();
      // no subscribers
      var hadEffect = e.broadcast();
      assert(hadEffect == false);
    
    1. A syntactical alternative to the broadcast method - notifySubscribers - has been added.
    Open source →
    Release notes

    This version has BREAKING CHANGES

    • Minimum Dart sdk dependency is now 3.4.0

    • An EventArgs instance is created and broadcast automatically if none provided, i.e.

    var e = Event(); // is equivalent to... var e = Event<EventArgs>();

    • An Event can have a name specified. Some code might be subscribed to more than one Event, so this lets one know which Event caused the code to run.

    var e = Event("CountUpdatedEvent"); e.subscribe((args) => print(args.eventName)); // outputs "null" until the event is broadcast. e.broadcast(); // outputs "CountUpdatedEvent"

    • EventArgs includes two accessible values:- eventName and whenOccurred. Both have a default value of null , and are only populated when the Event is broadcast.

    // Example without Event name var e = Event(); e.subscribe((args) { print(args.eventName); // outputs null print(args.whenOccurred); // outputs time of broadcast }; e.broadcast();

    // Example specifying an Event name var e = Event("myEvent"); e.subscribe((args) { print(args.eventName); // outputs "myEvent" print(args.whenOccurred); // outputs time of broadcast }; e.broadcast();

    • The WhenWhy EventArg derived class is DEPRECATED and removed. Use the EventArgs whenOccurred property instead.

    • The + and - equivalents to subscribe() and unsubscribe() have been DEPRECATED and removed for simplicity.

    • A custom ArgsError is thrown if an Event is broadcast() without an appropriate argument

    var e = Event<CustomEventArgs>(); // following throws an ArgsError because broadcast() // specifies no CustomEventArgs e.broadcast(); // In this case, the ArgsError message shown would be... // "Incorrect args being broadcast - args should be a CustomEventArgs"

    // instead, following is correct e.broadcast(CustomEventArgs("hello"));

    • A new property genericType has been added to the Event class. Gets the generic type of the Event, e.g.

    var e = Event<Value<int>>(); assert(e.genericType == Value<int>);

    • The broadcast() method now returns a bool, indicating if the broadcast had subscribers or not. No subscribers means the broadcast() method is effectively ignored.

    var e = Event(); // no subscribers var hadEffect = e.broadcast(); assert(hadEffect == false);

    • A syntactical alternative to the broadcast method - notifySubscribers - has been added.
    Open source →
  4. 2.1.2 11 Jan 2022
    Release notes
    • Small README changes
    Open source →
  5. 2.1.1 10 Jan 2022

    Nothing published for this version

  6. 2.1.0 10 Jan 2022
    Release notes
    • Improved README

    • ** Breaking Changes **

      • StdEventArgs renamed to WhenWhy to better indicate what the arguments represent.
      var e = Event<WhenWhy>();
      e.broadcast(WhenWhy(description: 'some info'));  
    
    • EventArgs Value and Values now derive from EventArgs rather than WhenWhy (formerly StdEventArgs).
    Open source →
    Release notes

    Improved README

    ** Breaking Changes **

    • StdEventArgs renamed to WhenWhy to better indicate what the arguments represent.

    var e = Event<WhenWhy>(); e.broadcast(WhenWhy(description: 'some info'));

    • EventArgs Value and Values now derive from EventArgs rather than WhenWhy (formerly StdEventArgs).
    Open source →
  7. 2.0.5 10 May 2021
    Release notes
    • Fix issue #5. Support the ability to unsubscribeAll within an Event handler.
    Open source →
  8. 2.0.4 10 May 2021
    Release notes
    • GenericEventArg1 and GenericEventArg2 Event argument types renamed to Value and Values. Better reflects common usage. Values supports two values, while Value supports one.
          var e = Event<Value>(); // Event will include a value as an argument
          e.broadcast(Value(39)); // type of the Value inferred to be an int
    
          // equivalent to 
    
          var e = Event<Value<int>>();  // type of the Value can also be explicit
          e.broadcast(Value(39));
    
    • Updated tests.
    Open source →
    Release notes
    • GenericEventArg1 and GenericEventArg2 Event argument types renamed to Value and Values . Better reflects common usage. Values supports two values, while Value supports one.

    var e = Event<Value>(); // Event will include a value as an argument e.broadcast(Value(39)); // type of the Value inferred to be an int

    // equivalent to

    var e = Event<Value<int>>(); // type of the Value can also be explicit e.broadcast(Value(39));

    • Updated tests.
    Open source →
  9. 2.0.3 10 May 2021
    Release notes
    • Make the list of handlers a non-nullable Type that is created lazily using the new 'late' keyword.

    This simplifies the code substantially, because no null checks etc. are required.

    Open source →
  10. 2.0.2 08 May 2021
    Release notes
    • Fixed issue #7 https://github.com/aryehof/dart-event/issues/7
    • Updated tests.
    Open source →
  11. 2.0.1 08 Mar 2021
    Release notes
    • Fixed incorrect link to Changelog in README.
    Open source →
  12. 2.0.0 08 Mar 2021
    Release notes
    • Null safe. (Min SDK version 2.12.0)
    • Changes to README content and layout.
    Open source →
  13. 1.1.5 28 Feb 2021
    Release notes
    • Minor changes to README content and layout.
    Open source →
    Release notes
    • Minor changes to README content and layout.
    Open source →
  14. 1.1.4 11 Jun 2020
    Release notes
    • Added a subscribeStream method to Event, which supports the broadcasting of Events to a Dart Stream [StreamSink].

      This allows a sequence of broadcast Events to be represented and manipulated as a Dart Stream. The rich range of mechanisms to filter and manipulate Streams become available.

      Remember that the supplied [StreamSink] should be closed when no longer needed.

      // Example
       var e = Event();
       var sc = StreamController();
      
       e.subscribeStream(sc.sink);
       e.broadcast();
      
       sc.stream.listen((e) => print('boom'));
       sc.close();
      
    Open source →
    Release notes

    Added a subscribeStream method to Event, which supports the broadcasting of Events to a Dart Stream [StreamSink].

    This allows a sequence of broadcast Events to be represented and manipulated as a Dart Stream . The rich range of mechanisms to filter and manipulate Streams become available.

    Remember that the supplied [StreamSink] should be closed when no longer needed.

    // Example var e = Event(); var sc = StreamController();

    e.subscribeStream(sc.sink); e.broadcast();

    sc.stream.listen((e) => print('boom')); sc.close();

    Open source →
  15. 1.1.3 17 Feb 2020
    Release notes
    • BasicEventArgs renamed to StdEventArgs for clarity.
    Open source →
  16. 1.1.2 09 Feb 2020
    Release notes
    • EventArgs changes
      • Added BasicEventArgs as a standard EventArgs derived type. It includes a whenOccurred field that contains the date and time the Event was broadcast, as well as an optional description field.
      • Renamed EventArgs1 and EventArgs2 to GenericEventArgs1 and GenericEventArgs2 respectively, to better indicate their purpose. Both are now derived from BasicEventArgs, meaning that they have whenOccurred and (optional) description fields.
      • Improvements to documentation
    • Minor improvements to Event documentation.
    Open source →
    Release notes
    • EventArgs changes

    • Added BasicEventArgs as a standard EventArgs derived type. It includes a whenOccurred field that contains the date and time the Event was broadcast , as well as an optional description field.

    • Renamed EventArgs1 and EventArgs2 to GenericEventArgs1 and GenericEventArgs2 respectively, to better indicate their purpose. Both are now derived from BasicEventArgs , meaning that they have whenOccurred and (optional) description fields.

    • Improvements to documentation

    • Minor improvements to Event documentation.

    Open source →
  17. 1.1.1 03 Feb 2020
    Release notes
    • Add new method unsubscribeAll, to unsubscribe all subscribers (handlers).
    Open source →
    Release notes
    • Add new method unsubscribeAll , to unsubscribe all subscribers (handlers).
    Open source →
  18. 1.1.0 30 Jan 2020
    Release notes

    Breaking Change

    The function signature for an Event has been simplified. The sender argument has been removed, leaving only the need to provide an optional argument derived from type EventArgs.

    The sender argument was previously intended to be used to provide the source of the Event, or the object in which the Event was declared, to a subscriber. This can be equally well done within an EventArg passed as an argument to a subscriber.

    // Before
    // subscribe to onValueChanged Event
    myCounter.onValueChanged + (sender, args) => print('before');
    
    // Now
    // subscribe to onValueChanged Event
    myCounter.onValueChanged + (args) => print('after');
    

    Other Breaking Changes

    • Renamed addHandler and removeHandler methods to subscribe and unsubscribe respectively.
    • Renamed raise methods to broadcast.
    • Method broadcastWithSubject removed to reflect to removal of sender described above.
    • The count method has been renamed to `subscriberCount'

    Other

    • Two general purpose EventArg derived classes (EventArgs1 and EventArgs2) have been included, which offers a quick alternative to producing your own custom EventArgs class.

    EventArgs1 supports one generic value, while EventArgs2 supports two. Example:-

    // EventArgs1 (one value)
    var e = Event<EventArgs1<String>>();
    e.subscribe((args) => print(args.value));
    e.broadcast(EventArgs1('hello'));
    // prints hello
    
    // EventArgs2 (two values)
    var e = Event<EventArgs2<String, int>>();
    e.subscribe((args) => print('${args.value1} - ${args.value2}'));
    e.broadcast(EventArgs2('boom', 37));
    // prints boom - 37
    
    Open source →
    Release notes

    Breaking Change

    The function signature for an Event has been simplified. The sender argument has been removed, leaving only the need to provide an optional argument derived from type EventArgs .

    The sender argument was previously intended to be used to provide the source of the Event, or the object in which the Event was declared, to a subscriber. This can be equally well done within an EventArg passed as an argument to a subscriber.

    // Before // subscribe to onValueChanged Event myCounter.onValueChanged + (sender, args) => print('before');

    // Now // subscribe to onValueChanged Event myCounter.onValueChanged + (args) => print('after');

    Other Breaking Changes

    • Renamed addHandler and removeHandler methods to subscribe and unsubscribe respectively.

    • Renamed raise methods to broadcast .

    • Method broadcastWithSubject removed to reflect to removal of sender described above.

    • The count method has been renamed to `subscriberCount'

    Other

    • Two general purpose EventArg derived classes ( EventArgs1 and EventArgs2 ) have been included, which offers a quick alternative to producing your own custom EventArgs class.

    EventArgs1 supports one generic value, while EventArgs2 supports two. Example:-

    // EventArgs1 (one value) var e = Event<EventArgs1<String>>(); e.subscribe((args) => print(args.value)); e.broadcast(EventArgs1('hello')); // prints hello

    // EventArgs2 (two values) var e = Event<EventArgs2<String, int>>(); e.subscribe((args) => print('${args.value1} - ${args.value2}')); e.broadcast(EventArgs2('boom', 37)); // prints boom - 37

    Open source →
  19. 1.0.3 23 Jan 2020
    Release notes
    • Added image of elevator example to README.
    Open source →
  20. 1.0.2 23 Jan 2020
    Release notes
    • Updated reference to Flutter [EventSubscriber] in the README.
    • Minor documentation improvements
    Open source →
    Release notes
    • Updated reference to Flutter EventSubscriber in the README.

    • Minor documentation improvements

    Open source →
  21. 1.0.0 23 Jan 2020
    Release notes
    • Initial release
    Open source →
    Release notes
    • Initial release

    48

    likes

    150

    points

    16.5k

    downloads

    Documentation

    API reference

    Publisher

    aryehoffman.com

    Weekly Downloads

    Metadata

    Create lightweight custom Events, that allow interested subscribers to be notified that something has happened.

    Repository (GitHub)

    View/report issues

    License

    Apache-2.0 ( license )

    More

    Packages that depend on event

    ← Metadata

    48

    likes

    150

    points

    16.5k

    downloads

    Documentation

    API reference

    Publisher

    aryehoffman.com

    Weekly Downloads

    Metadata

    Create lightweight custom Events, that allow interested subscribers to be notified that something has happened.

    Repository (GitHub)

    View/report issues

    License

    Apache-2.0 ( license )

    More

    Packages that depend on event

    Back

    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive