Minh Nguyen
Minh Nguyen

Reputation: 2039

Firebase "once" event does not return promise

In official document of firebase https://www.firebase.com/docs/web/api/query/once.html. It writed

Return Value

Returns a Promise that can optionally be used instead of the successCallback and failureCallback to handle success and failure.

But in my example code there are no promise return when call 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 error because of no promise returned.
.then(function(){
    console.log('promise called');
});

Please see full code at jsfiddle: http://jsfiddle.net/7e4j77q7/5/

What i'm doing wrong here? How can i let once function return promise?

Upvotes: 1

Views: 1884

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136194

It seems like you are using older version of firebase, the DOC you are referring has 2.4.2 version & you had older version 1.0.11

Upvotes: 2

Related Questions