isar / hive

Lightweight and blazing fast key-value database written in pure Dart.
Apache License 2.0
4.07k stars 404 forks source link

Need for stream #890

Closed themumy10 closed 2 years ago

themumy10 commented 2 years ago

I m trying to listen for changes in box by using bloc pattern. I need stream subscription for my database changes.

We need a watch method for box. Because of lazy initialization of the box I think this is not possible. So instead of lazy box we may divide boxes into two categories.

We need an un-lazy box to subscribe changes in database changes

Version

raveesh-me commented 2 years ago

Use a StreamController / StreamSink and make the watcher add events on that sink. Simple.

themumy10 commented 2 years ago

Watcher event does not update on add to box. While using a bloc pattern design watch method doesn't update on add event

gosemathraj commented 2 years ago

@themumy10 this seems to work for listening box changes.

Hive.box("user").listenable().addListener(() { voidCallback.call(); });