Skip to content

Commit

Permalink
fix: ModelNotifier change support
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Sep 12, 2022
1 parent ea748e3 commit dfe252c
Show file tree
Hide file tree
Showing 48 changed files with 666 additions and 886 deletions.
2 changes: 1 addition & 1 deletion packages/firebase_model_notifier/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ packages:
name: model_notifier
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+3"
version: "0.14.0+4"
nm:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions packages/katana/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ packages:
name: coverage
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
version: "1.6.0"
crypto:
dependency: "direct main"
description:
Expand Down Expand Up @@ -203,7 +203,7 @@ packages:
name: pointycastle
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "3.6.2"
pool:
dependency: transitive
description:
Expand Down
16 changes: 8 additions & 8 deletions packages/katana_firebase/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ packages:
name: cloud_firestore
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.6"
version: "3.4.7"
cloud_firestore_platform_interface:
dependency: transitive
description:
name: cloud_firestore_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "5.7.3"
version: "5.7.4"
cloud_firestore_web:
dependency: transitive
description:
name: cloud_firestore_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.6"
version: "2.8.7"
collection:
dependency: transitive
description:
Expand Down Expand Up @@ -217,7 +217,7 @@ packages:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "1.21.1"
version: "1.22.0"
firebase_core_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -253,7 +253,7 @@ packages:
name: font_awesome_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "10.1.0"
version: "10.2.1"
http:
dependency: transitive
description:
Expand Down Expand Up @@ -288,14 +288,14 @@ packages:
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.1+3"
version: "0.14.0"
katana_flutter:
dependency: "direct main"
description:
name: katana_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.0+8"
version: "0.14.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -456,7 +456,7 @@ packages:
name: pointycastle
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "3.6.2"
process:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions packages/katana_flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ packages:
name: font_awesome_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "10.1.0"
version: "10.2.1"
http:
dependency: transitive
description:
Expand Down Expand Up @@ -246,7 +246,7 @@ packages:
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.1+3"
version: "0.14.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -407,7 +407,7 @@ packages:
name: pointycastle
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "3.6.2"
process:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion packages/katana_module/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ packages:
name: model_notifier
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+3"
version: "0.14.0+4"
nm:
dependency: transitive
description:
Expand Down
12 changes: 6 additions & 6 deletions packages/katana_routing/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ packages:
name: flutter_riverpod
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.3+1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -223,7 +223,7 @@ packages:
name: font_awesome_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "10.1.0"
version: "10.2.1"
google_fonts:
dependency: "direct main"
description:
Expand Down Expand Up @@ -265,14 +265,14 @@ packages:
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.1+3"
version: "0.14.0"
katana_flutter:
dependency: "direct main"
description:
name: katana_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.0+8"
version: "0.14.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -433,7 +433,7 @@ packages:
name: pointycastle
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "3.6.2"
process:
dependency: transitive
description:
Expand All @@ -447,7 +447,7 @@ packages:
name: riverpod
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "1.0.3+1"
share_plus:
dependency: transitive
description:
Expand Down
73 changes: 2 additions & 71 deletions packages/masamune/lib/adapter/inherited_model_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,79 +133,10 @@ class InheritedModelAdapter<
linkedCollectionPath: "$_prefix$linkedCollectionPath$_suffix",
);

/// Performs the process of loading a document.
///
/// Usually, you specify a method that can be executed only the first time, such as [loadOnce] or [listen].
///
/// If you set [listen] to `false`, [loadOnce] is used even if the model can use [listen].
@override
TDocument loadDocument(
TDocument document, {
bool listen = true,
}) =>
adapter.loadDocument(
document,
listen: listen,
);

/// Performs the process of loading a collection.
///
/// Usually, you specify a method that can be executed only the first time, such as [loadOnce] or [listen].
///
/// If you set [listen] to `false`, [loadOnce] is used even if the model can use [listen].
@override
TCollection loadCollection(
TCollection collection, {
bool listen = true,
}) =>
adapter.loadCollection(
collection,
listen: listen,
);

/// Reload the given [document].
///
/// There is no effect with respect to the document being listened to.
@override
Future<TDocument> reloadDocument(TDocument document) =>
adapter.reloadDocument(document);

/// Reload the given [collection].
///
/// There is no effect with respect to the collection being listened to.
@override
Future<TCollection> reloadCollection(TCollection collection) =>
adapter.reloadCollection(collection);

/// Loads data for the next cursor further in the [collection] that has been read.
@override
Future<TCollection> loadNextCollection(TCollection collection) =>
adapter.loadNextCollection(collection);

/// Deletes information associated with a document.
@override
Future<void> deleteDocument(TDocument document) =>
adapter.deleteDocument(document);

/// Retrieves a document from a [collection].
///
/// By specifying [id], you can specify the ID of newly created document. If not specified, [uuid] will be used.
@override
TDocument createDocument(
TCollection collection, [
String? id,
]) =>
adapter.createDocument(collection, id);

/// Retrieves a document from a [path].
@override
TDocument createDocumentFromPath(String path) =>
adapter.createDocumentFromPath("$_prefix$path$_suffix");

/// Save the data in the document so that you can use it after restarting the app.
@override
Future<void> saveDocument(TDocument document) =>
adapter.saveDocument(document);
TDocument createDocument(String path) =>
adapter.createDocument("$_prefix$path$_suffix");

/// Upload your media.
///
Expand Down
84 changes: 1 addition & 83 deletions packages/masamune/lib/adapter/local_model_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,94 +100,12 @@ class LocalModelAdapter extends ModelAdapter<LocalDynamicDocumentModel,
linkedCollectionPath: linkedCollectionPath,
);

/// Performs the process of loading a document.
///
/// Usually, you specify a method that can be executed only the first time, such as [loadOnce] or [listen].
///
/// If you set [listen] to `false`, [loadOnce] is used even if the model can use [listen].
@override
LocalDynamicDocumentModel loadDocument(
LocalDynamicDocumentModel document, {
bool listen = true,
}) {
document.loadOnce();
return document;
}

/// Performs the process of loading a collection.
///
/// Usually, you specify a method that can be executed only the first time, such as [loadOnce] or [listen].
///
/// If you set [listen] to `false`, [loadOnce] is used even if the model can use [listen].
@override
LocalDynamicCollectionModel loadCollection(
LocalDynamicCollectionModel collection, {
bool listen = true,
}) {
collection.loadOnce();
return collection;
}

/// Reload the given [document].
///
/// There is no effect with respect to the document being listened to.
@override
Future<LocalDynamicDocumentModel> reloadDocument(
LocalDynamicDocumentModel document,
) async {
await document.reload();
return document;
}

/// Reload the given [collection].
///
/// There is no effect with respect to the collection being listened to.
@override
Future<LocalDynamicCollectionModel> reloadCollection(
LocalDynamicCollectionModel collection,
) async {
await collection.reload();
return collection;
}

/// Loads data for the next cursor further in the [collection] that has been read.
@override
Future<LocalDynamicCollectionModel> loadNextCollection(
LocalDynamicCollectionModel collection,
) async {
await collection.next();
return collection;
}

/// Deletes information associated with a document.
@override
Future<void> deleteDocument(LocalDynamicDocumentModel document) async {
await document.delete();
}

/// Retrieves a document from a [collection].
///
/// By specifying [id], you can specify the ID of newly created document. If not specified, [uuid] will be used.
@override
LocalDynamicDocumentModel createDocument(
LocalDynamicCollectionModel collection, [
String? id,
]) {
return collection.create(id);
}

/// Retrieves a document from a [path].
@override
LocalDynamicDocumentModel createDocumentFromPath(String path) {
LocalDynamicDocumentModel createDocument(String path) {
return LocalDynamicDocumentModel(path);
}

/// Save the data in the document so that you can use it after restarting the app.
@override
Future<void> saveDocument(LocalDynamicDocumentModel document) async {
await document.save();
}

/// Upload your media.
///
/// Folder can be specified by specifying [folderPath].
Expand Down
Loading

0 comments on commit dfe252c

Please sign in to comment.