Skip to content

track value callback completion in firebaseLoads #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/reactfire.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
var value = snapshot.val();

this.data[bindVar] = _createRecord(key, value);
this.firebaseLoads[bindVar] = true;

this.setState(this.data);
}
Expand Down Expand Up @@ -229,6 +230,15 @@
this.setState(this.data);
}

/**
* 'value' listener which updates the 'load' state of the bound state variable.
*
* @param {string} bindVar The state variable to which the data is being bound.
*/
function _arrayValue(bindVar) {
this.firebaseLoads[bindVar] = true;
this.setState(this.data);
}

/*************/
/* BINDING */
Expand Down Expand Up @@ -266,7 +276,8 @@
child_added: firebaseRef.on('child_added', _arrayChildAdded.bind(this, bindVar), cancelCallback),
child_removed: firebaseRef.on('child_removed', _arrayChildRemoved.bind(this, bindVar), cancelCallback),
child_changed: firebaseRef.on('child_changed', _arrayChildChanged.bind(this, bindVar), cancelCallback),
child_moved: firebaseRef.on('child_moved', _arrayChildMoved.bind(this, bindVar), cancelCallback)
child_moved: firebaseRef.on('child_moved', _arrayChildMoved.bind(this, bindVar), cancelCallback),
value: firebaseRef.on('value', _arrayValue.bind(this, bindVar), cancelCallback)
};
} else {
// Add listener for 'value' event
Expand All @@ -288,6 +299,7 @@
this.data = {};
this.firebaseRefs = {};
this.firebaseListeners = {};
this.firebaseLoads = {};
},

/**
Expand Down