events_emitter2 1.0.4 copy "events_emitter2: ^1.0.4" to clipboard
events_emitter2: ^1.0.4 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
150
points
187
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

logging, meta, synchronized

More

Packages that depend on events_emitter2