Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

cancellable function

let resp = await new Promise(function(resolve, reject) {
    // simulating time consuming process
    setTimeout(() => resolve('Promise RESOLVED !'), 3000);
    // hit a button to cancel the promise
    $('#btn').click(() => resolve('Promise CANCELED !'));
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #cancellable #function
ADD COMMENT
Topic
Name
3+8 =