googlearchive / firebase-util

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

Scroll + Normalized #67

Closed bogdantmm92 closed 9 years ago

bogdantmm92 commented 9 years ago

This is not exactly an issue, but more of a question. I have these lines:

var msgsRef = Utils.usersRef.child(this.props.userId).child('notebook/messages');
var scrollRef = new Firebase.util.Scroll(msgsRef, 'date');
var norm = new Firebase.util.NormalizedCollection(
       scrollRef,
       [membersRef, 'members', 'messages.fromId'],
       [Utils.ref.child('users'), 'users', 'messages.fromId']
    );
var normalizedRef = norm.select('......

I want to be able to paginate through the normalized ref. Any idea how to structure the refs? If I try to compose the scrollRef out of normalizedRef, it gives me this error: First argument to Firebase.util.Scroll must be a valid Firebase ref. It cannot be a Query (e.g. you have called orderByChild()).

katowulf commented 9 years ago

Create the normalized ref first and pass it into the Scroll/Paginate classes.

laurensnl commented 8 years ago

I did this:

// map the paths we are going to join
var norm = new Firebase.util.NormalizedCollection(
    FB.child('sessions'),
    [FB.child('accounts'), 'accounts', 'sessions.user']
);

// specify the fields for each path
norm = norm.select( 'sessions.user', 'sessions.loginTime', 'sessions._sort', ... );

// get a reference we can use like a normal Firebase instance
var scrollRef = new Firebase.util.Scroll(norm.ref(), '_sort');

The initial data is loaded correctly, but no subsequent data is loaded on scroll. Infinite scrolling does work when I replace the Normalized Collection ref to a standard Firebase ref. What am I doing wrong here?

firebase#2.2.9 firebase-util#0.2.6