add method
Adds a new callback.
callbackSpecify the callback to add.callbackKeySpecify a key for the callback that can be used to identify the callback. If not specified, the callback itself will be used as the key.
Returns a function that removes the callback.
Implementation
void Function() add(TCallback<T1> callback, {dynamic callbackKey}) {
if (this._queue.isNotEmpty) {
Here().debugLogAlert(
'Do not add callbacks while callbacks are executing. Call wait() first.',
);
}
final k = callbackKey ?? callback;
this._callbacks[k] = callback;
return () => this._callbacks.remove(k);
}