Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript execute function after async

function a() {
    return new Promise(function(resolve) {
        setTimeout(function() {
            console.log('a');
            resolve();
        }, 500)
    });
}

function b() {
    return new Promise(function(resolve) {
        setTimeout(function() {
            console.log('b');
            resolve();
        }, 250);
    });
}

a().then(b).then(function() {/* do something else */})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #execute #function #async
ADD COMMENT
Topic
Name
2+3 =