mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-27 00:59:28 +01:00
23 lines
556 B
Dart
23 lines
556 B
Dart
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();
|
|
});
|
|
}
|