Merge pull request #8491 from Benefex/master

Updated firebase query method .once to optionally return a promise
This commit is contained in:
Masahiro Wakame
2016-03-12 01:30:32 +09:00
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -700,11 +700,18 @@ wilmaRef.transaction(function(currentData) {
}, { x: 1 });
}
() => {
// Use a Promise in place of a callback
firebaseRef.once('value').then(function(dataSnapshot){
// handle read data
})
}
/*
* FirebaseQuery.orderByChild()
*/
() => {
// For example, using our sample Firebase of dinosaur facts,
// For example, using our sample Firebase of dinosaur facts,
// we can read all dinosaurs ordered by height using the following query:
var ref = new Firebase("https://dinosaur-facts.firebaseio.com/");
ref.orderByChild("height").on("child_added", function (snapshot) {
+1
View File
@@ -109,6 +109,7 @@ interface FirebaseQuery {
*/
once(eventType: string, successCallback: (dataSnapshot: FirebaseDataSnapshot) => void, context?: Object): void;
once(eventType: string, successCallback: (dataSnapshot: FirebaseDataSnapshot) => void, failureCallback?: (error: any) => void, context?: Object): void;
once(eventType: string): Promise<FirebaseDataSnapshot>
/**
* Generates a new Query object ordered by the specified child key.
*/