Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 5 additions & 71 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"@angular/platform-browser": "^20.0.0",
"@angular/router": "^20.0.0",
"@angular/service-worker": "^20.0.0",
"rxjs": "~6.6.7",
"rxjs-compat": "^6.6.7",
"rxjs": "^7.8.2",
"tslib": "^2.6.0",
"unfetch": "^4.1.0",
"zone.js": "~0.15.0"
Expand Down
10 changes: 5 additions & 5 deletions src/app/feeds/feed/feed.component.ts

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Unused Observable import retained in feed component

Line 2 imports Observable from rxjs, but it is never used anywhere in the FeedComponent class. This was also unused before the PR (imported from rxjs previously). A minor cleanup opportunity — lint rules should catch this.

(Refers to line 2)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing unused import, not touched by this PR — leaving it for the Wave 4 lint tooling pass to catch.

Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export class FeedComponent implements OnInit {
this.pageSub = this.route.params.subscribe(params => {
this.pageNum = params['page'] ? +params['page'] : 1;
this._hackerNewsAPIService.fetchFeed(this.feedType, this.pageNum)
.subscribe(
items => this.items = items,
error => this.errorMessage = 'Could not load ' + this.feedType + ' stories.',
() => {
.subscribe({
next: items => this.items = items,
error: () => this.errorMessage = 'Could not load ' + this.feedType + ' stories.',
complete: () => {
this.listStart = ((this.pageNum - 1) * 30) + 1;
window.scrollTo(0, 0);
}
);
});
});
}
}
11 changes: 7 additions & 4 deletions src/app/item-details/item-details.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { Subscription } from 'rxjs/Subscription';
import { Subscription } from 'rxjs';

import { HackerNewsAPIService } from '../shared/services/hackernews-api.service';
import { SettingsService } from '../shared/services/settings.service';
Expand Down Expand Up @@ -33,9 +33,12 @@ export class ItemDetailsComponent implements OnInit {
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
let itemID = +params['id'];
this._hackerNewsAPIService.fetchItemContent(itemID).subscribe(item => {
this.item = item;
}, error => this.errorMessage = 'Could not load item comments.');
this._hackerNewsAPIService.fetchItemContent(itemID).subscribe({
next: item => {
this.item = item;
},
error: () => this.errorMessage = 'Could not load item comments.'
});
});
window.scrollTo(0, 0);
}
Expand Down
5 changes: 2 additions & 3 deletions src/app/shared/services/hackernews-api.service.ts

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Poll content fetches lack error handling, now with different RxJS 7 unhandled-error semantics

The fetchPollContent subscribe at src/app/shared/services/hackernews-api.service.ts:28 uses .subscribe(pollResults => {...}) with no error handler. This is pre-existing, but the RxJS 6→7 upgrade changes how unhandled errors are reported: RxJS 7 uses reportUnhandledError (via setTimeout) instead of throwing synchronously. If a poll content fetch fails, the error will surface as an uncaught async error rather than being thrown on the call stack. This won't crash the app but changes error observability. Since this wasn't touched by the PR and the single-argument subscribe form is not deprecated, it's not a bug in the PR itself.

(Refers to lines 28-31)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged — pre-existing behavior, and the single-argument subscribe(next) form remains supported in RxJS 7. Leaving as-is to keep this PR scoped to the RxJS 7 migration.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable, map } from 'rxjs';
import fetch from 'unfetch';
import {map } from 'rxjs/operators';

import { Story } from '../models/story';
import { User } from '../models/user';
Expand Down Expand Up @@ -45,7 +44,7 @@ export class HackerNewsAPIService {
}
}

function lazyFetch<T>(url, options?) {
function lazyFetch<T>(url: string, options?: RequestInit) {
return new Observable<T>(fetchObserver => {
let cancelToken = false;
fetch(url, options)
Expand Down
11 changes: 7 additions & 4 deletions src/app/user/user.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { Subscription } from 'rxjs/Subscription';
import { Subscription } from 'rxjs';

import { HackerNewsAPIService } from '../shared/services/hackernews-api.service';
import { User } from '../shared/models/user';
Expand All @@ -26,9 +26,12 @@ export class UserComponent implements OnInit {
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
let userID = params['id'];
this._hackerNewsAPIService.fetchUser(userID).subscribe(data => {
this.user = data;
}, error => this.errorMessage = 'Could not load user ' + userID + '.');
this._hackerNewsAPIService.fetchUser(userID).subscribe({
next: data => {
this.user = data;
},
error: () => this.errorMessage = 'Could not load user ' + userID + '.'
});
});
}

Expand Down