events_emitter
0.6.0, released 2 years ago by drafakiller.com
An intuitive event-based system inspired by NodeJS's Event Emitter with type safety.
What it does
Provides an event-based system with type safety, allowing multiple data types for events. It supports both callbacks and streams through EventEmitter and StreamEventEmitter, and can be extended to create custom event emitters.
AI-written summary of version 0.6.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want a NodeJS-style event emitter in Dart or Flutter
- You need type-safe event handling where multiple data types share an event type
- You want to use both callbacks and streams for managing events
Skip it when
- You already use a state management solution that covers your event communication needs
- You prefer built-in StreamControllers without external abstractions
Strengths
- Type-safe events allowing different data types on the same event type
- Supports both callbacks and streams
- Extensible classes to create custom event emitters and events
Weaknesses
- Can introduce event-driven architectural complexity if overused in a UI codebase
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
final events = EventEmitter();
events.on('message', (String data) => print('String: $data'));
events.on('message', (int data) => print('Integer: $data'));
events.emit('message', 'Hello World');
events.emit('message', 42);Alternatives
Packages that do the same job and could replace events_emitter.
- ordered_set
Ordered Set that keeps elements sorted and allows duplicates by priority.
82Compare - snowplow_tracker
Flutter package for sending Snowplow analytics events on Android, iOS, and Web.
78Compare - async_events
A portable asynchronous event hub supporting multiple storage types.
67Compare - geotypes
Lightweight library providing GeoJSON data types for Dart and Flutter
50Compare
Works with
Packages commonly used together with events_emitter: ones it builds on, ones built on it, and its own family.
- rxdartevents_emitter depends on itImplementation of the ReactiveX API for asynchronous programming leveraging native Dart Streams.
- unleash_proxy_client_flutterBuilt on events_emitterA client for integrating Unleash feature management and evaluating feature flags in Flutter applications.
- threadBuilt on events_emitterType-safe isolated thread with event emitter for async communication
- peerdartBuilt on events_emitterSimple peer-to-peer WebRTC wrapper for Dart and Flutter supporting data and media streams.