Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/core/store/hive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ part of 'iface.dart';

/// The store of Hive.
///
/// It implements [Store].
class HiveStore extends Store {
/// The internal hive box for this [Store].
/// It implements [KvStore].
class HiveStore extends KvStore {
/// The internal hive box for this [KvStore].
///
/// Not `final`: [init] may run a second time on the same instance after
/// `Hive.close()`, which is how an app recovers from box files it turned out
Expand Down
18 changes: 9 additions & 9 deletions lib/src/core/store/iface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef StoreFromObj<T extends Object> = T? Function(Object? val);
/// {@macro store_from_to}
typedef StoreToObj<T extends Object> = Object? Function(T? value);

/// The interface of any [Store].
/// The interface of any [KvStore].
///
/// The provider of the store can be `shared_preferences`, `hive`, `sqflite`, etc.
///
Expand All @@ -35,7 +35,7 @@ typedef StoreToObj<T extends Object> = Object? Function(T? value);
///
/// It's designed that only one timestamp for all the data in one store.
/// {@endtemplate}
sealed class Store {
sealed class KvStore {
/// Serializes changes that read, replace, or restore [lastUpdateTs].
///
/// The map is persisted as one value, so two asynchronous writers cannot
Expand All @@ -60,7 +60,7 @@ sealed class Store {
/// Name of the store
final String name;

Store({
KvStore({
required this.name,
this.updateLastUpdateTsOnSet = StoreDefaults.defaultUpdateLastUpdateTs,
this.updateLastUpdateTsOnRemove = StoreDefaults.defaultUpdateLastUpdateTs,
Expand Down Expand Up @@ -279,7 +279,7 @@ sealed class Store {
}
}

/// The interface of a single Property in any [Store].
/// The interface of a single Property in any [KvStore].
///
/// Such as the `user_token` in `shared_preferences`, `user` in `hive`, etc.
abstract class StoreProp<T extends Object> {
Expand All @@ -304,7 +304,7 @@ abstract class StoreProp<T extends Object> {
/// - [fromObj] & [toObj], you can refer to [StoreFromObj] & [StoreToObj].
/// - [store] is the store of the property.
/// - [updateLastUpdateTsOnSetProp] is whether to update the last update timestamp
///of this [Store] when setting a value for this property.
///of this [KvStore] when setting a value for this property.
/// {@endtemplate}
const StoreProp(
this.key, {
Expand All @@ -313,8 +313,8 @@ abstract class StoreProp<T extends Object> {
this.updateLastUpdateTsOnSetProp = StoreDefaults.defaultUpdateLastUpdateTs,
});

/// It's [Store].
Store get store;
/// It's [KvStore].
KvStore get store;

/// Get the value of the key.
T? get() => store.get(key, fromObj: fromObj);
Expand Down Expand Up @@ -355,7 +355,7 @@ abstract class StoreProp<T extends Object> {
bool get updateLastUpdateTsOnSet => store.updateLastUpdateTsOnSet && updateLastUpdateTsOnSetProp;
}

/// The interface of a single Property in any [Store] which has a default value.
/// The interface of a single Property in any [KvStore] which has a default value.
///
/// Such as the `user_token` in `shared_preferences`, `user` in `hive`, etc.
abstract class StorePropDefault<T extends Object> extends StoreProp<T> {
Expand Down Expand Up @@ -389,7 +389,7 @@ abstract class StorePropDefault<T extends Object> extends StoreProp<T> {
}

/// The keys used internally in the store.
extension StoreDefaults on Store {
extension StoreDefaults on KvStore {
/// {@template store_defaults_prefix_key}
/// The prefix of the internal keys.
///
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/store/mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ part of 'iface.dart';

// ignore_for_file: unnecessary_this

/// A mock implementation of [Store] that keeps data in memory.
/// A mock implementation of [KvStore] that keeps data in memory.
/// Persistence operations complete asynchronously, matching production stores.
class MockStore extends Store {
class MockStore extends KvStore {
final Map<String, Object> _mem = {};

MockStore({
Expand Down
2 changes: 1 addition & 1 deletion lib/src/core/store/pref.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef PrefStoreKeyListener = void Function(String key);
/// {@template PrefStore.init}
/// `MUST` call [init] before using any pref stores.
/// {@endtemplate}
final class PrefStore extends Store {
final class PrefStore extends KvStore {
/// The prefix of SharedPreferences.
///
/// Defaults to `''`.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/store/sqlite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ CREATE TABLE IF NOT EXISTS kv (

/// The store of SQLite.
///
/// It implements [Store]. Values are JSON, so what comes back out of [get] is
/// It implements [KvStore]. Values are JSON, so what comes back out of [get] is
/// what `jsonDecode` produces — a `Map`, a `List` or a primitive — and the
/// `fromObj` hook every caller already passes is what turns it back into a
/// model. That is the same path [HiveStore] used for anything without a
/// `TypeAdapter`, now the only path.
class SqliteStore extends Store {
class SqliteStore extends KvStore {
/// Constructor.
SqliteStore(
String name, {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/core/sync/iface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class Mergeable {
/// Returns true if any changes were made to the store.
static Future<bool> mergeStore({
required Map<String, Object?> backupData,
required Store store,
required KvStore store,
required bool force,
}) async {
bool hasChanges = false;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/provider/app.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.