Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
How to resolve this promise

I'm applying this library which is called noty and I want to resolve this promise. Here is the code.

    var bouncejsClose = function (promise) {
    var n = this;
    new Bounce()
        .translate({
            from: { x: 0, y: 0 }, to: { x: 450, y: 0 },
            easing: 'bounce',
            duration: 500,
            bounces: 4,
            stiffness: 1
        })
        .applyTo(n.barDom, {
            onComplete: function () {
                promise(function (resolve) {
                    resolve();
                });
            }
        });
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't resolve a Promise from outside of its declaration, what you need to do is:


var bouncejsClosePromise = new Promise((resolve, reject) => {
  var n = this;
  new Bounce()
    .translate({
      from: { x: 0, y: 0 },
      to: { x: 450, y: 0 },
      easing: "bounce",
      duration: 500,
      bounces: 4,
      stiffness: 1
    })
    .applyTo(n.barDom, {
      onComplete: function () {
        //now you can resolve here
        resolve(/** with any value you want to get when calling .then method */)
      }
    });
});

bouncejsClosePromise.then((/** if you pass value to the resolve callback, you can get it here */) => {
  //your promise successfully resolved
}).catch(() => {
  //or in case you used reject in your promise, you can handle it here
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!