JSFiddle - React, Tailwind, and code Playground
by Ryan Mitchell
HTML
<button id="tester">Click to test.</button>
JavaScript
Promise = function() {
this.result = null;
this._getPuntos = function() {
var deferred = $.Deferred();
setTimeout(function(scope) {
scope.result = "It works."
deferred.resolve("It works.");
}, 500, this);
return deferred.promise();
}
this.getPuntos = function()
{
var promise = this._getPuntos();
return promise;
}
this.getResults = function() {
return this.result;
};
}
$("#tester").click(function() {
var test = new Promise();
$.when(test.getPuntos()).then(function() {
alert(test.getResults());
});
});