fix: earthquake 頁面 - #2
Merged
Merged
Conversation
7 tasks
This was referenced Nov 10, 2025
Merged
7 tasks
This was referenced Dec 29, 2025
Merged
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.