1

I have a plugin I'm writing for a framework that uses Promises throughout. The plugin is expected to return a Promise to process the event, and anything the plugin does during processing is chained before returning the next event. I think...

Anyway - I am also using an older library that is completely callback based - and the callback doesn't follow the standard convention of having callback(err,resp) as the last parameter.

How do I turn this:

var call = libary.Api(_this.config.url, function(response){return new Promise() {Do my actions with the response..}}, _this.config.api_key);

return BbPromise.try(call).then(evt);

Into a Promise that depends on the callback being processed?

Silver
  • 4,911
  • 3
  • 15
  • 16

1 Answers1

0

Try this:

return (new BbPromise(function(resolve) {
    libary.Api(_this.config.url, function(response) {
        resolve(response);
    }, _this.config.api_key);
})).then(evt);
Bob Sponge
  • 4,708
  • 1
  • 23
  • 25