isar / isar/hive

BoxBase.asyncGet would be nice

Open
#820 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

It would be nice to be able to make the choice between `Box` and `LazyBox` an easy configuration option in an app. That would easier and more elegant if `BoxBase` defined an `asyncGet` method. `Box`'s implementation would just return `Future.value(get(key))`.

This would have saved me this bit of reflective, somewhat fragile code ("fragile" because there might someday be other subtypes of `BoxBase`):
```
BoxBase box = thing passed to us;
Object? cached;
if (box is LazyBox) {
cached = await (box as LazyBox).get(key);
} else {
cached = (box as Box).get(key);
await Future.value(null);
// So that future returned from this method is added to the
// map before method completes
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.