Skip to content

fix: earthquake 頁面 - #2

Merged
yayacat merged 6 commits into
ExpTechTW:Releasefrom
yayacat:Release
Oct 2, 2023
Merged

fix: earthquake 頁面#2
yayacat merged 6 commits into
ExpTechTW:Releasefrom
yayacat:Release

Conversation

@yayacat

@yayacat yayacat commented Oct 2, 2023

Copy link
Copy Markdown
Member

No description provided.

@yayacat
yayacat merged commit 3fbdc85 into ExpTechTW:Release Oct 2, 2023
@claude claude Bot mentioned this pull request Nov 23, 2025
7 tasks
This was referenced Dec 29, 2025
whes1015 added a commit that referenced this pull request Jul 12, 2026
…ycle + staleness)

Add the realtime data spine the review's item #2 called for, wired to EEW as
the first consumer through the existing EewRepository (Result contract intact).

Engine (lib/core/realtime/), all behind injectable seams (Clock, Elapsed,
Ticker, RealtimeSource) so it is fully unit-testable with hand-written fakes:
- RealtimeChannel<T> polls a RealtimeSource<T> on a fixed cadence, folds
  Result into an immutable RealtimeState<T> (connecting/live/stale/offline),
  and exposes a broadcast Stream that emits once per observable change.
- Staleness is a pure, golden-pinned classifier measured against a MONOTONIC
  Elapsed, so a device-clock jump or ServerClock offset resync can never
  reclassify a dead feed as live. A failed poll keeps the last data and the
  feed ages on its own.
- RealtimeService fans app lifecycle out to channels (pause on background;
  on foreground recompute status → resume → fire-and-forget clock resync),
  bridged to Flutter by an AppLifecycleListener adapter and to provider by a
  RealtimeNotifier ChangeNotifier.
- ServerClock corrects device time via a bounded, best-effort NTP sync (used
  for display/payload timestamps, not for EEW status).

EEW consumer: EewRealtimeSource (data/) over the repository; EewRealtimeController
(presentation/) exposes alerts/status. Wired in bootstrap + a _RealtimeHost that
starts polling post-first-frame and disposes on teardown.

Hardened against a 4-lens adversarial review (7 confirmed findings fixed, each
locked by a test): in-flight fetch discarded across background via an epoch
guard; onForeground no longer blocks resume behind the clock sync; monotonic
staleness immune to clock jumps/offset changes with a negative-age guard;
refreshNow awaits an already in-flight poll.

Tests: staleness golden table, RealtimeState equality, ServerClock offset/
timeout, RealtimeChannel behaviour (aging, failure-retention, in-flight guard,
pause/resume ordering, discard-across-pause, fan-out, dispose), RealtimeService
fan-out order, EewRealtimeSource passthrough. Documented in CLAUDE.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant