isar / isar/hive

box.putAll(Map) triggering watch event Map.entries.length amount of time

Open
#1,026 3 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Question**
Is it possible for Hive to trigger BoxEvent only once when using putAll method? Now when adding map of entries to a box it gets triggered as many times as there are entries.

**Code sample**
using this code:
```dart
box.watch().map(
(BoxEvent _) {
print("watchAll: " + T.toString() + " " + _.toString());
return box.values.toList();
},
)
```
I'm getting this output:
```
I/flutter (14849): watchAll: Reward Instance of 'BoxEvent'
I/flutter (14849): watchAll: Reward Instance of 'BoxEvent'
I/flutter (14849): watchAll: Reward Instance of 'BoxEvent'
I/flutter (14849): watchAll: Reward Instance of 'BoxEvent'
I/flutter (14849): watchAll: Reward Instance of 'BoxEvent'
I/flutter (14849): watchAll: Reward Instance of 'BoxEvent'
I/flutter (14849): watchAll: Reward Instance of 'BoxEvent'
I/flutter (14849): watchAll: Reward Instance of 'BoxEvent'
```

**Version**
- Platform: iOS, Android, Web
- Flutter version: Flutter 3.0.3 • channel stable
- Hive version: 2.2.1
- Hive_flutter version: 1.1.0
- Hive_generator version: 1.1.3

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Box.putAll and box.watch entry points described in the issue, then reproduce the sample using a multi-entry map on the listed Hive and Flutter versions. Done means one batch produces a single BoxEvent instead of one event per entry, with coverage for the observed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.