JSFiddle - React, Tailwind, and code Playground
HTML
<button id="tester">Click to test.</button>
JavaScript
function getPuntos(puntosHandler) {
var deferred = $.Deferred();
setTimeout(function() {
deferred.resolve("It works.")
}, 500);
deferred.promise().done(puntosHandler);
return deferred.promise();
}
function resultHandler(resultFromPuntos) {
alert(resultFromPuntos);
}
$("#tester").click(function() {
getPuntos(resultHandler);
});