-
-
Save dimovdaniel/0ba453a691e784a01c021495712bc679 to your computer and use it in GitHub Desktop.
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
sleep(miliseconds) { | |
var currentTime = new Date().getTime(); | |
while (currentTime + miliseconds >= new Date().getTime()) { | |
} | |
} | |
/** | |
* Step 3 | |
* Connect to firebase to get the current item we need | |
*/ | |
getDataFromFirebase(firebasePath){ | |
this.sleep(1000) | |
var ref=firebase.app.database().ref(firebasePath); | |
var _this=this; | |
// Callback pattern | |
ref.on('value', function(snapshotRoot) { | |
var isJustArray=Common.getClass(snapshotRoot.val())=="Array"; | |
if(isJustArray){ | |
//Since Nov 2017, quering an array directly always returns 10 rows. | |
//Anyway, wnen we do query an array direclty, we need to get all the items, so we know the array real length | |
//So, we will go the old fashion way, quering firebase directly | |
console.log("Fix for limited paging on arrays") | |
ref.once('value').then(function(snapshot) { | |
console.log("Received compleete array with length of "+snapshot.val().length); | |
_this.processRecords(snapshot.val()) | |
}); | |
}else{ | |
_this.processRecords(snapshotRoot.val()) | |
} | |
}); | |
} |
my code looks different than yours. i am using the new version. please help me out.
getDataFromFirebase(firebasePath){
//The paging options
var options = Config.adminConfig.paging||{
pageSize: 20,
finite: true,
retainLastPage: false
};
var ref=firebase.app.database().ref(firebasePath);
var paginator = new FirebasePaginator(ref,options);
var _this=this;
// Callback pattern
paginator.on('value', function() {
console.log(paginator.collection.length);
var isJustArray=Common.getClass(paginator.collection)=="Array";
if(isJustArray){
//Since Nov 2017, quering an array directly always returns 10 rows.
//Anyway, wnen we do query an array direclty, we need to get all the items, so we know the array real length
//So, we will go the old fashion way, quering firebase directly
console.log("Fix for limited paging on arrays")
ref.once('value').then(function(snapshot) {
console.log("Received compleete array with length of "+snapshot.val().length);
_this.processRecords(snapshot.val())
});
}else{
_this.processRecords(paginator.collection)
}
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace the getDataFromFirebase function in "src/Containers/Fireadmin.js" around line 200.
Important: don't forget to add sleep function.