add support for named args
This commit is contained in:
@@ -241,7 +241,7 @@ class Channel {
|
||||
debounce(
|
||||
timeout: Duration(seconds: 1),
|
||||
target: updateAttachment,
|
||||
arguments: [
|
||||
positionalArguments: [
|
||||
it.copyWith(
|
||||
uploadState: UploadState.inProgress(uploaded: sent, total: total),
|
||||
),
|
||||
@@ -1695,7 +1695,7 @@ class ChannelClientState {
|
||||
debounce(
|
||||
timeout: Duration(milliseconds: 500),
|
||||
target: _channel._client.chatPersistenceClient?.updateChannelState,
|
||||
arguments: [v],
|
||||
positionalArguments: [v],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,19 @@ Map<Function, Timer> timeouts = {};
|
||||
void debounce({
|
||||
@required Duration timeout,
|
||||
@required Function target,
|
||||
@required List arguments,
|
||||
List positionalArguments,
|
||||
Map<Symbol, dynamic> namedArguments,
|
||||
}) {
|
||||
if (timeouts.containsKey(target)) {
|
||||
timeouts[target].cancel();
|
||||
}
|
||||
|
||||
final timer = Timer(timeout, () {
|
||||
Function.apply(target, arguments);
|
||||
Function.apply(
|
||||
target,
|
||||
positionalArguments,
|
||||
namedArguments,
|
||||
);
|
||||
});
|
||||
|
||||
timeouts[target] = timer;
|
||||
|
||||
Reference in New Issue
Block a user