on method
EventEmitterListener
on({
- required String eventName,
- required FutureOr onCallback(
- EventEmitterListener listener,
- dynamic update
- Map? stateData,
Implementation
EventEmitterListener on({
required String eventName,
required FutureOr<dynamic> Function(
EventEmitterListener listener, dynamic update)
onCallback,
Map? stateData,
}) {
final Map<String, EventEmitterListener> event_datas =
events.putIfAbsent(eventName, () {
return {};
});
final EventEmitterListener eventEmitterListenerGeneralLib =
EventEmitterListener(
stateData: stateData ?? {},
);
eventEmitterListenerGeneralLib.ensureInitiaLized(
eventName: eventName,
eventUniqueId: generateNewUniqueId(event_datas: event_datas),
onUpdate: onCallback,
onCancel: (event) {
event_datas.remove(event.event_unique_id);
remove(eventName: eventName, uniqueId: event.event_unique_id);
event.dispose();
},
);
event_datas[eventEmitterListenerGeneralLib.event_unique_id] =
eventEmitterListenerGeneralLib;
return eventEmitterListenerGeneralLib;
}