on method
EventEmitterListener
on(})
receive all update data
Implementation
EventEmitterListener on(
String type_update,
FutureOr<dynamic> Function(UpdateTd update) callback, {
final Map<dynamic, dynamic>? stateData,
void Function(Object data)? onError,
}) {
return event_emitter.on(
eventName: type_update,
stateData: stateData ?? {},
onCallback: (listener, update) async {
try {
if (update is TdlibIsolateReceiveData) {
// final TdlibIsolateReceiveData tdlibIsolateReceiveData = update;
await callback(UpdateTd(
update: update.updateData,
client_id: update.clientId,
client_option: () {
try {
final TdlibClient? tdlibClient = clients[update.clientId];
if (tdlibClient != null) {
return tdlibClient.client_option;
}
} catch (e) {}
return {};
}(),
));
return;
}
} catch (e) {
if (onError != null) {
return onError(e);
}
}
},
);
}