Instantly share code, notes, and snippets.

@uno-de-piera uno-de-piera/afire.service.ts Secret
Last active May 26, 2018

Embed
What would you like to do?
import { Injectable } from '@angular/core';
import {AngularFirestore, DocumentChangeAction} from 'angularfire2/firestore';
@Injectable({
providedIn: 'root'
})
export class AfireService {
constructor(
private afs: AngularFirestore,
) {}
paginate (limit: number, last: string): Observable<DocumentChangeAction<any>[]> {
return this.afs.collection('todos', (ref) => (
ref
.where('id', '<', last)
.orderBy('id', 'desc')
.limit(limit)
)).snapshotChanges();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment