Skip to content

Commit 2985260

Browse files
authoredAug 3, 2023
osama/cancel_old_timer_to_avoid_redundant api_calls_from_old_timers (#272)
- cancel old timer to avoid redundant api calls from old timers
1 parent 213c704 commit 2985260

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed
 

‎lib/state/server_time/server_time_cubit.dart

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class ServerTimeCubit extends Cubit<ServerTimeState> {
2727
void _connectionListener(ConnectionState state) {
2828
_fetchServerTime(state);
2929

30+
if (_serverTimeInterval != null && _serverTimeInterval!.isActive) {
31+
_serverTimeInterval!.cancel();
32+
}
3033
_serverTimeInterval = Timer.periodic(
3134
_fetchServerTimeDuration,
3235
(Timer timer) => _fetchServerTime(state),

0 commit comments

Comments
 (0)