import { Component , OnInit } from '@angular/core' ; import { FeedsService } from '../../../common/services/feeds.service' ; /**
 * A default recommendations feed - can be accessed by logged-out users.
 * Users subscribers of a recommendations user on the backend.
 */ @ Component ( { selector : 'm-defaultFeed' , providers : [ FeedsService ] , templateUrl : 'feed.component.html' , styleUrls : [ './feed.component.ng.scss' ] , } ) export class DefaultFeedComponent implements OnInit { constructor ( public feedsService ) { } public ngOnInit ( ) { this . load ( true ) ; } returns { void } public loadNext ( ) { if ( this . feedsService . canFetchMore && ! this . feedsService . inProgress . getValue ( ) && this . feedsService . offset . getValue ( ) ) { this . feedsService . fetch ( ) ; } this . feedsService . loadMore ( ) ; } param { boolean } returns { void } private load ( refresh = false ) { if ( refresh ) { this . feedsService . clear ( true ) ; } try { this . feedsService . setEndpoint ( `api/v3/newsfeed/default-feed` ) . setLimit ( 12 ) . fetch ( refresh ) ; } catch ( e ) { console . error ( 'DefaultFeedComponent' , e ) ; } } }