According to the official Firebase documentation located at here, it states:
Return Value
Returns a Promise that can optionally be used instead of the successCallback and failureCallback to handle success and failure.
However, in my specific code example, I noticed that there is no promise being returned when calling the "once" function.
fb.once('value', function(snapshoot){
snapshoot.forEach(function(snap){
var book = new Book(snap);
$scope.bookList.push(book);
$scope.$apply();
});
})
//Following lines below cause an error because no promise is returned.
.then(function(){
console.log('promise called');
});
You can view the full code on jsfiddle: here
What am I doing wrong here? How can I make the "once" function return a promise?