Estoy aplicando esta biblioteca que se llama noty y quiero resolver esta promesa. Aquí está el código.
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(); }); } }); };No puede resolver una Promise desde outside de su declaración, lo que debe hacer es:
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 })