feat: Update translations, finish saved views rework, some other fixes

This commit is contained in:
Anton Stubenbord
2023-09-22 00:46:24 +02:00
parent f3560f00ea
commit 18ab657932
55 changed files with 2049 additions and 1087 deletions

View File

@@ -8,25 +8,26 @@ abstract class PersistentRepository<T> extends HydratedCubit<T> {
PersistentRepository(T initialState) : super(initialState);
void addListener(
Object source, {
Object subscriber, {
required void Function(T) onChanged,
}) {
onChanged(state);
_subscribers.putIfAbsent(source, () {
_subscribers.putIfAbsent(subscriber, () {
return stream.listen((event) => onChanged(event));
});
}
void removeListener(Object source) async {
await _subscribers[source]?.cancel();
_subscribers.remove(source);
_subscribers
..[source]?.cancel()
..remove(source);
}
@override
Future<void> close() {
_subscribers.forEach((key, subscription) {
subscription.cancel();
});
for (final subscriber in _subscribers.values) {
subscriber.cancel();
}
return super.close();
}
}