- 
                Notifications
    
You must be signed in to change notification settings  - Fork 105
 
Open
Description
I'm hoping to achieve something like this:
function createSpooky() {
    return new Promise(function (resolve) {
        var spooky = new Spooky(opts, function (err) {
            if (err) {
                var e = new Error('Failed');
                e.details = err;
                throw e;
            }
            resolve(spooky)
        });
    });
}That way, I could do something like:
createSpooky().then(function (spooky) {
    spooky.open('https://google.com');
    //Initialize the rest of our spooky steps here!
});Every time I try to resolve spooky via that promise, however, I get an error (kinda); Uncaught, unspecified "error" event. ([object Object]).
I'm not sure how to continue from here. Maybe this is my lack of understanding promises fully, or spooky's limitations, but is such a thing possible? Am I going about it completely wrong? I'm just hoping to avoid callback hell and I really like to chain my thens (i.e. createSpooky().then(doStuff).then(doMoreStuff)
Metadata
Metadata
Assignees
Labels
No labels