-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip drop: `RepositoryV2` wip #377
- Loading branch information
Showing
9 changed files
with
55 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,10 @@ | ||
import 'package:mem/framework/repository/entity.dart'; | ||
|
||
abstract class KeyWithValue<Key, Value> extends EntityV2 { | ||
final Key key; | ||
final Value value; | ||
|
||
KeyWithValue(this.key, this.value); | ||
|
||
@override | ||
String toString() => { | ||
"key": key, | ||
"value": value, | ||
}.toString(); | ||
} | ||
|
||
// FIXME IdWithValueの方が命名として適切なのでは? | ||
mixin KeyWithValueV2<KEY, VALUE> on Entity { | ||
mixin KeyWithValue<KEY, VALUE> on Entity { | ||
late final KEY key; | ||
late final VALUE value; | ||
|
||
@override | ||
Map<String, dynamic> get toMap => {'key': key, 'value': value}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
import 'package:mem/framework/repository/key_with_value.dart'; | ||
import 'package:mem/framework/repository/repository.dart'; | ||
|
||
abstract class KeyWithValueRepository<E extends KeyWithValue<Key, dynamic>, Key> | ||
extends RepositoryV2<E> | ||
with Receiver<E, bool>, DiscarderByKey<E, Key, bool> {} | ||
|
||
mixin DiscarderByKey<E extends KeyWithValue<Key, dynamic>, Key, Result> | ||
on RepositoryV2<E> { | ||
Future<Result> discard(Key key); | ||
} | ||
|
||
abstract class KeyWithValueRepositoryV2< | ||
ENTITY extends KeyWithValueV2<KEY, dynamic>, | ||
ENTITY extends KeyWithValue<KEY, dynamic>, | ||
KEY> extends Repository<ENTITY> { | ||
Future<void> receive(ENTITY entity); | ||
|
||
Future<void> discard(int key); | ||
Future<void> discard(KEY key); | ||
|
||
Future<void> discardAll(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
import 'package:mem/framework/repository/entity.dart'; | ||
import 'package:mem/framework/repository/key_with_value.dart'; | ||
import 'package:mem/settings/preference_key.dart'; | ||
|
||
class Preference<T> extends KeyWithValue<PreferenceKey<T>, T?> { | ||
Preference(super.key, super.value); | ||
class PreferenceEntity<VALUE> | ||
with Entity, KeyWithValue<PreferenceKey<VALUE>, VALUE?> { | ||
PreferenceEntity(PreferenceKey<VALUE> key, VALUE? value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
// coverage:ignore-start | ||
@override | ||
Entity copiedWith() => throw UnimplementedError(); | ||
|
||
// coverage:ignore-end | ||
} |