Added throttle on refetch queries on AppLifecycleChange
This commit is contained in:
parent
e0f6ac2356
commit
cb8c65bec1
12
lib/app.dart
12
lib/app.dart
@ -2,6 +2,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:persistent_bottom_nav_bar_v2/persistent-tab-view.dart';
|
||||
@ -41,8 +42,15 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
log("AppLifecycle: ${state.toString()}");
|
||||
|
||||
if(state == AppLifecycleState.resumed) {
|
||||
NotificationTasks.updateProviders(context);
|
||||
Provider.of<TimetableProps>(context, listen: false).run();
|
||||
EasyThrottle.throttle(
|
||||
"appLifecycleState",
|
||||
const Duration(seconds: 10),
|
||||
() {
|
||||
log("Refreshing due to LifecycleChange");
|
||||
NotificationTasks.updateProviders(context);
|
||||
Provider.of<TimetableProps>(context, listen: false).run();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user