EventService constructor
EventService(
- List<
MineralEventContract> events
Implementation
EventService(List<MineralEventContract> events): super(inject: true) {
register(events);
controller.stream.listen((_event) {
final regexp = RegExp(r'^([a-zA-Z0-9_]+)<.*>$|^([a-zA-Z0-9_]+)$');
final match = regexp.firstMatch(_event.runtimeType.toString());
final eventType = match?.group(1) ?? match?.group(2);
final events = _events.entries.firstWhereOrNull((event) => event.key.toString().startsWith(eventType.toString()));
if (events != null) {
for (final event in events.value) {
event.handle(_event);
}
}
});
}