Saturday, 13 May 2017

Bluebird PromisifyAll on Backbone not resolving

Particularly i want to promisify model.fetch method, so when I'm creating model I promisifying Backbone

function (_, Backbone, Promise) {
  Backbone = Promise.promisifyAll(Backbone);
  var Diagram = Backbone.Model.extend({...});
}

But later I'm trying to use fetchAsync, on my diagram model and nothing happens.

diagram.fetchAsync()
   .then(function() {
     console.log('success');
   },
   function() {
     console.log('err');
   })
   .catch(function() {
      console.error('fetch failed');
   });

in console this promise looks like this

_bitField: 0
_fulfillmentHandler0: undefined
_promise0: undefined
_receiver0: undefined
_rejectionHandler0: undefined
__proto__: Object

I think that fetchAsync calls non promisifyed versions of sync and ajax calls that do not return resolve in this promise. I'm new to promises so sorry if I wrote something silly.

On promisifying backbone I found very little info in google, just several packages on npm, but I don't want to include extra packages, especcially if they are not popular.



via Alexander

No comments:

Post a Comment