felangel / bloc

A predictable state management library that helps implement the BLoC design pattern

Home Page:https://bloclibrary.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: Make hydrated_storage.dart:Storage.read() method async

iulian0512 opened this issue · comments

Description

I want to provide my own sqlite backed implementation of Storage but i need the read method to be async like the rest of the methods in Storage class, most sqlite libs execute queries async.

Desired Solution

Make the read method Future

/// Interface which is used to persist and retrieve state changes.
abstract class Storage {
  /// Returns value for key async
  Future<dynamic> read(String key);

Alternatives Considered

A workaround of loading an entire table in memory to be accessible to synchronous read method is sub-optimal to say at least.

Additional Context

image
The errror above appears randomly on some devices. In the past i have used hive for other purposes and had to eliminate it due to this, hive works but its not reliable, it has issues especially when android apps are paused/resumed.