mirror of
https://github.com/immich-app/immich.git
synced 2026-05-30 19:35:19 -04:00
8d5d12b108
* chore: upgrade flutter to 3.44.0 # Conflicts: # mise.lock * static analysis fix * fix ios ci --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
20 lines
770 B
Dart
20 lines
770 B
Dart
import 'package:immich_mobile/domain/models/setting.model.dart';
|
|
import 'package:immich_mobile/domain/services/store.service.dart';
|
|
|
|
// Singleton instance of SettingsService, to use in places
|
|
// where reactivity is not required
|
|
// ignore: non_constant_identifier_names
|
|
final AppSetting = SettingsService(storeService: StoreService.I);
|
|
|
|
class SettingsService {
|
|
final StoreService _storeService;
|
|
|
|
const SettingsService({required this._storeService});
|
|
|
|
T get<T>(Setting<T> setting) => _storeService.get(setting.storeKey, setting.defaultValue);
|
|
|
|
Future<void> set<T>(Setting<T> setting, T value) => _storeService.put(setting.storeKey, value);
|
|
|
|
Stream<T> watch<T>(Setting<T> setting) => _storeService.watch(setting.storeKey).map((v) => v ?? setting.defaultValue);
|
|
}
|