Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluebird: Promise.defer is deprecated #8

Open
Jolg42 opened this issue Oct 14, 2016 · 0 comments
Open

Bluebird: Promise.defer is deprecated #8

Jolg42 opened this issue Oct 14, 2016 · 0 comments

Comments

@Jolg42
Copy link

Jolg42 commented Oct 14, 2016

Hi,

I used node-connection-example and got this warning from Bluebird lib

Warning: Promise.defer is deprecated and will be removed in a future version. Use new Promise instead.
    at EventEmitter.NodeConnection.connect (file:///Users/user/node-connection-example/js/components/generator-connection/lib/NodeConnection.js:269:32)
    at EventEmitter.NodeDomain (file:///Users/user/node-connection-example/js/components/generator-connection/lib/NodeDomain.js:81:46)
    at HTMLDocument.<anonymous> (file:///Users/user/node-connection-example/js/app/main.js:XX:XX)
    at fire (file:///Users/user/node-connection-example/js/components/jquery/dist/jquery.js:3099:30)
    at Object.add [as done] (file:///Users/user/node-connection-example/js/components/jquery/dist/jquery.js:3145:7)
    at jQuery.fn.ready (file:///Users/user/node-connection-example/js/components/jquery/dist/jquery.js:3378:25)
    at jQuery.fn.init (file:///Users/user/node-connection-example/js/components/jquery/dist/jquery.js:2821:16)
    at jQuery (file:///Users/user/node-connection-example/js/components/jquery/dist/jquery.js:76:10)
    at file:///Users/user/node-connection-example/js/app/main.js:21:5
    at Object.execCb (file:///Users/user/node-connection-example/js/components/requirejs/require.js:1690:33)
    at Object.check (file:///Users/user/node-connection-example/js/components/requirejs/require.js:865:51)
    at Object.<anonymous> (file:///Users/user/node-connection-example/js/components/requirejs/require.js:1140:34)
    at file:///Users/user/node-connection-example/js/components/requirejs/require.js:131:23

Apparently the deprecation is old and needs to be fixed http://bluebirdjs.com/docs/deprecated-apis.html


exceljs/exceljs#48 (comment)

Instead of doing:

var deferred = Promise.defer();
doSomething(function cb(err, res) {
    if (err) deferred.reject(err); else deferred.resolve(res);
});
return deferred.promise;

You should do:

return new Promise(function(resolve, reject) {
    doSomething(function cb(err, res) {
        if (err) reject(err); else resolve(res);
    });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant