Created
November 27, 2016 11:37
-
-
Save kyle-ssg/5c78e9af511773848a2d934b267c43c5 to your computer and use it in GitHub Desktop.
Firebase paging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loadMore = (ref, from, qty, reverse=false)=> { | |
var direction = reverse ? 'endAt' : 'startAt'; | |
return ref['direction'](null,from) | |
.limitToFirst(qty+1) | |
.once('value') | |
.then((snap)=>{ | |
var items = snap.val() || {}; | |
var res = {hasMore:false, items}; | |
delete items[from]; | |
res.hasMore = Object.keys(items).length == qty; | |
return res | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment