GartorwareCorp / firebase-util

An experimental toolset for Firebase
http://firebase.github.io/firebase-util
MIT License
8 stars 9 forks source link

FIREBASE WARNING: Exception thrown by user callback #16

Open r3wt opened 7 years ago

r3wt commented 7 years ago

The paginator works fine. I currently has 33 items in the node I am paginating. The page size is 30. when i attempt to navigate to the 2nd page, which should have 3 items, the following error is displayed in the console:

FIREBASE WARNING: Exception was thrown by user callback. Qh@http://localhost:3000/dist/firebase/firebase.js:472:117 g.Nd@http://localhost:3000/dist/firebase/firebase.js:482:298 require<[4]</n.prototype._queryRef@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:8842 require<[4]</n.prototype._subscribe@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:9299 require<[4]</n.prototype._listen/<@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:10200 require<[4]</n.prototype._grow/<@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:8596 c@http://localhost:3000/dist/firebase/firebase.js:477:56 g.Tb/<@http://localhost:3000/dist/firebase/firebase.js:437:829 fc@http://localhost:3000/dist/firebase/firebase.js:301:165 bf@http://localhost:3000/dist/firebase/firebase.js:366:215 af@http://localhost:3000/dist/firebase/firebase.js:365:343 Fh@http://localhost:3000/dist/firebase/firebase.js:460:426 g.gc@http://localhost:3000/dist/firebase/firebase.js:475:140 g.$f@http://localhost:3000/dist/firebase/firebase.js:477:246 require<[4]</n.prototype._grow@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:8200 require<[4]</n.prototype._listen@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:10150 require<[4]</n.prototype.goTo@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:7251 require<[3]</n.prototype.moveTo@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:2857 require<[5]</n.prototype._pageChange@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:13602 require<[5]</n.prototype.setPage@http://localhost:3000/dist/custom/firebase-util-paginate.min.js:9:11931 list.go@http://localhost:3000/dist/custom/firebasePaginator.js:43:4 anonymous/fn@http://localhost:3000/dist/angular/angular.js line 15358 > Function:2:259 ngEventHandler/</callback@http://localhost:3000/dist/angular/angular.js:26994:17 $RootScopeProvider/this.$get</Scope.prototype.$eval@http://localhost:3000/dist/angular/angular.js:18161:16 $RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost:3000/dist/angular/angular.js:18261:20 ngEventHandler/<@http://localhost:3000/dist/angular/angular.js:26999:17 defaultHandlerWrapper@http://localhost:3000/dist/angular/angular.js:3734:3 createEventHandler/eventHandler@http://localhost:3000/dist/angular/angular.js:3722:9

I'm using a thin wrapper around this library:


angular.module('firebasePaginator',[])
.factory('$firebasePaginator',function($firebaseArray){

    return function(ref, field, pageSize, cb) {

        cb = cb|| function(){};
        // create a Paginate reference
        var pageRef = new firebase.util.Paginate(ref, field, {maxCacheSize: 250,pageSize: pageSize});
        // generate a synchronized array using the special page ref
        var list = $firebaseArray(pageRef);

        list.loaded = false;
        // store the "page" scope on the synchronized array for easy access
        list.currentPage = 1;
        list.ref = pageRef;
        list.ready = false;

        list.$loaded().then(function(){
            list.loaded = true;
            cb(list);
        });

        pageRef.page.onPageCount(function(currentPageCount, couldHaveMore) {
          list.pageCount = currentPageCount;
          list.couldHaveMore = couldHaveMore;
          list.ready = true;
        });

        // when the current page is changed, update local scope vars
        pageRef.page.onPageChange(function(p) {
          list.currentPage = p;
        });

        list.go = function( page ){
            page = ~~page;
            if(page < 1){
                page = 1;
            }
            if(page > list.pageCount){
                page = list.pageCount;
            }
            pageRef.page.setPage(page);
        };

        list.next = function(){
            pageRef.page.next();
        };

        list.prev = function(){
            pageRef.page.prev();
        };

        // load the first page
        pageRef.page.next();

        return list;

    }

});

I'm not sure what the problem here is. Going to try and dig into it.