isar / hive

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

Get value from Box Event to make my query in hive #750

Open tazik561 opened 3 years ago

tazik561 commented 3 years ago

Why I can't find an example about watch listener? I have this method :

  Stream<List<VocabularyModel>> watchVocabsFromdb() => hiveService.vocabularyBox
      .watch()
      .map((event) => hiveService.vocabularyBox.values
          .where((element) => element.remember == true)
          .toList());

I want every time my box is changed I get new value so I wrote above code, But I always receive empty value In the event that in this method return values :

  List<VocabularyModel> getRememberVocabsFromdb() =>
      hiveService.vocabularyBox.values
          .where((element) => element.remember == true)
          .toList();

How can I get value from Box Event to make my query?

fernando-s97 commented 3 years ago

I'm not sure if it's the same case, but this code always return the old values:

box.watch().listen((event) => box.values);

I'm wondering "why"?