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

Type-safe, multi-listenable, dispose safe event handling classes

example/events_emitter2_example.dart

import 'package:events_emitter2/src/events_emitter.dart';

abstract class CalculationEvent {}

class CalculationResults extends CalculationEvent {
  final num results;
  CalculationResults({required this.results});
}

class Calculator with EventsEmittable<CalculationEvent> {
  void add(num a, num b) {
    events.emit(CalculationResults(results: a + b));
  }
}

void main(List<String> args) {
  var calculator = Calculator();
  var listener = calculator.createListener();
  listener
      .on<CalculationResults>((event) => print("Got results ${event.results}"));
  calculator.add(1, 2);
  listener.dispose();
}
1
likes
0
pub points
41%
popularity

Publisher

unverified uploader

Type-safe, multi-listenable, dispose safe event handling classes

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

logging, meta, synchronized

More

Packages that depend on events_emitter2