Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda