Skip to content

Instantly share code, notes, and snippets.

@sanchezcarlosjr
Last active June 4, 2020 02:38
Show Gist options
  • Save sanchezcarlosjr/845e9ac4c38b955aa84bcccfe3102b4e to your computer and use it in GitHub Desktop.
Save sanchezcarlosjr/845e9ac4c38b955aa84bcccfe3102b4e to your computer and use it in GitHub Desktop.
Getting data from Firestore and Fetching
<div>
<div *ngFor="let article of articles | async">
<h1>{{article.title}}</h1>
<p><{{article.content}}/p>
<p>{{article.created_at}}</p>
</div>
</div>
<-- Whatever component -->
<ion-infinite-scroll threshold="100px" (ionInfinite)="loadData($event)">
<ion-infinite-scroll-content loadingSpinner="crescent" loadingText="Loading...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
export class PortfolioComponent implements OnInit, OnDestroy {
@Select(RacesState.articles) articles: Observable<Article[]>;
constructor(private store: Store, private news: NewsFirestore) {}
ngOnInit(): void {
this.store.dispatch(new Fetch());
}
ngOnDestroy(): void {
this.store.dispatch(new DisconnectStream(new Fetch()));
}
loadData(event: any): void {
this.news.more(() => event.target.complete());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment