deasync icon indicating copy to clipboard operation
deasync copied to clipboard

how to get promise result

Open wideweide opened this issue 1 year ago • 0 comments

function SyncFunction(){ var ret; setTimeout(function(){
ret = "hello"; },3000);

// may be promise.then(res=>ret=res) while(ret === undefined) { require('deasync').sleep(100); } // returns hello with sleep; undefined without return ret;
}

// may be promise.then(res=>ret=res)? but it seems waste time to wait?

is there better method?

wideweide avatar Jan 10 '24 12:01 wideweide