Add optional realtime updates mode with Firebase SDK integration #127
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.
Add optional realtime updates mode with Firebase SDK integration
Summary
This PR implements an optional realtime updates feature that allows users to see new Hacker News stories appear automatically without refreshing the page. When enabled in Settings, the app subscribes to the official Hacker News Firebase Realtime Database API and prepends new stories to the feed as they are posted.
Key Changes:
RealtimeUpdatesServiceto manage Firebase subscriptions and story updatesrealtimeUpdatestoggleFeedComponentto integrate realtime updates (only on page 1 of feeds)RealtimeUpdatesServiceReview & Testing Checklist for Human
getFeedPath()are correct, especially'news' -> 'v0/topstories'. The official HN Firebase API docs should confirm this.Test Plan
npm installnpm startlocalhost:4200Notes
child_addedevents which fire for all existing items on initial subscription. I mitigate this with aseenStoryIdsSet that tracks already-loaded stories, but there's a potential race condition if the REST API fetch and Firebase subscription happen simultaneously.SettingsServicenow implementsOnDestroy, but since it's a root-level singleton,ngOnDestroywill likely never be called in practice.Session: https://app.devin.ai/sessions/28354384d4914097a9c95e7775a075d1
Requested by: Luke Page (luke.page@cognition.ai) / @lukepage-COG