mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 23:02:43 +01:00
refresh lists on source change and sync
This commit is contained in:
22
lib/app/hooks/use_on_source.dart
Normal file
22
lib/app/hooks/use_on_source.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import '../state/services.dart';
|
||||
import '../state/source.dart';
|
||||
|
||||
void useOnSourceChange(WidgetRef ref, void Function(int sourceId) callback) {
|
||||
final sourceId = ref.watch(sourceIdProvider);
|
||||
|
||||
useEffect(() {
|
||||
callback(sourceId);
|
||||
return;
|
||||
}, [sourceId]);
|
||||
}
|
||||
|
||||
void useOnSourceSync(WidgetRef ref, void Function() callback) {
|
||||
final syncService = ref.watch(syncServiceProvider);
|
||||
|
||||
useOnListenableChange(syncService, () {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user