javascript - How does the asynchronous function return the final value? -


when use dojo framework create class, class has method uses asynchronous function, , else can make return final value, not promise or other?

you must use callback function, example:

function mydojofunction(id, callback) {    require(['dojo/dom'], function (dom) {       if (dom.byid(id)) callback (true);    }); } 

to call function:

mydojofunction('myid', function (exists) {    if (exists) console.log('i'm here');    else console.log('i'm not here'); }); 

that's way return if working dojo amd instead of legacy.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -