carp-dk / carp-dk/carp_study_app
fix(leak): MeasurementsCardViewModel.samplingTable subscribes to the measurement stream on every getter call
- Dominant language
- Dart
- Stars
- 10
- Forks
- 5
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 14
Description
## Problem
(verified) The `samplingTable` *getter* calls `quietMeasureEvents?.listen(...)` and returns the map (`lib/view_models/cards/measurements_data_model.dart:22-29`) — every UI read adds another permanent subscription, and each measurement is then counted N times, so the displayed sampling counts are also **wrong**, not just leaky. The correct `init()` implementation sits commented out directly below (:48-58).
## Proposed fix
Subscribe once in `init()`, store the `StreamSubscription`, cancel in `dispose()`/`clear()`; the getter returns the map only.
## Acceptance criteria
- [ ] Counts increment exactly once per measurement (unit test with a synthetic stream)
- [ ] Only one subscription exists regardless of rebuild count
**Effort:** S · **Priority:** P0 · **Change risk:** Low
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.