-
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.
v0.9 — Abstracted cache & enhanced RestrrOptions accessibility (#21)
* Abstracted cache & enhanced RestrrOptions accessibility * Updated CHANGELOG.md & version
- Loading branch information
1 parent
8f8b701
commit 3df8b9e
Showing
21 changed files
with
142 additions
and
186 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:restrr/restrr.dart'; | ||
|
||
abstract interface class EntityCacheView<E extends RestrrEntity<E, ID>, ID extends EntityId<E>> { | ||
E? get(ID id); | ||
List<E> getAll(); | ||
E add(E entity); | ||
E? remove(ID id); | ||
void removeWhere(bool Function(E) predicate); | ||
bool contains(ID id); | ||
void clear(); | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:restrr/restrr.dart'; | ||
|
||
class EntityCacheViewImpl<E extends RestrrEntity<E, ID>, ID extends EntityId<E>> implements EntityCacheView<E, ID> { | ||
final Map<ID, E> _cache = {}; | ||
|
||
@override | ||
E? get(ID id) => _cache[id]; | ||
|
||
@override | ||
List<E> getAll() => _cache.values.toList(); | ||
|
||
@override | ||
E add(E entity) => _cache[entity.id] = entity; | ||
|
||
@override | ||
E? remove(ID id) => _cache.remove(id); | ||
|
||
@override | ||
void removeWhere(bool Function(E p1) predicate) => _cache.removeWhere((k, v) => predicate(v)); | ||
|
||
@override | ||
bool contains(ID id) => _cache.containsKey(id); | ||
|
||
@override | ||
void clear() => _cache.clear(); | ||
} |
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
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
Oops, something went wrong.