-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Problem
When creating/updating data on a remote data source developers might want to update the local cache after that.
Desired Solution
In the most basic cases something like this could solve it.
Create:
// foo_repository.dart
@EditCache
Future<Foo> createFoo(Foo foo) async {
await dataSource.create(foo);
return foo;
}
leading to
// foo_repository.cached.dart
@override
Future<Foo> createFoo(Foo foo) async {
final result = await super.createFoo(foo);
_getFooCached["${foo.hashCode}"] = result;
return result;
}
Update:
// foo_repository.dart
Future<Foo> getFoo() async {
// ...
}
@EditCache
Future<Foo> updateFoo(int a, String b) async {
await dataSource.update(a, b);
final foo = getFoo();
return foo.copyWith(a:a, b:b);
}
leading to
// foo_repository.cached.dart
@override
Future<Foo> updateFoo(int a, String b) async {
final result = await super.updateFoo(a, b);
_getFooCached["${foo.hashCode}"] = result;
return result;
}
Alternatives Considered
No response
On which platorm do you expect this solution?
All
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers