From c073a058bb7e97e6a9319e88f3f7765d4a466bd0 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Mar 2021 08:37:10 +0200 Subject: Updated feed's subscriptions to use an observer object --- src/app/components/feed/feed.component.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/app/components/feed/feed.component.ts') diff --git a/src/app/components/feed/feed.component.ts b/src/app/components/feed/feed.component.ts index eaa0ef1..a9a042c 100644 --- a/src/app/components/feed/feed.component.ts +++ b/src/app/components/feed/feed.component.ts @@ -49,27 +49,27 @@ export class FeedComponent implements OnInit { fileUpload: new FormControl('') }); - this._userService.getUserFromSessionStorageRequest().subscribe( - (res: object) => { + this._userService.getUserFromSessionStorageRequest().subscribe({ + next: (res: object) => { Object.assign(this.user, res); this.loadFeed(); }, - () => { + error: () => { this.logout(); } - ); + }); } private loadFeed(): void { - this._feedService.getUserFeedFromSessionStorageRequest(this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe( - (result: object) => { + this._feedService.getUserFeedFromSessionStorageRequest(this._currentPage++, this._timeLoaded, AppConstants.PAGE_SIZE).subscribe({ + next: (result: object) => { this.posts.push(...Object.values(result)[0]); this.finishUserLoading(); }, - () => { + error: () => { this.finishUserLoading(); } - ); + }); } private finishUserLoading(): void { @@ -102,14 +102,14 @@ export class FeedComponent implements OnInit { const postMessage = this.createPostFormGroup.get('newPostMessage')?.value; this.dataArrived = false; - this._postService.createPostWithSessionStorageRequest(postMessage, this.files).subscribe( - () => { + this._postService.createPostWithSessionStorageRequest(postMessage, this.files).subscribe({ + next: () => { this.goToProfile(); }, - () => { + error: () => { this.dataArrived = true; } - ); + }); } onScroll(event: any): void { -- cgit v1.2.3