Please note This is a contrived example.
function longFunc(){
var deferred = $.Deferred();
setTimeout(function(){
console.log(\"
There is a trick, define an array or object and value it in then:
let Result=[];
let callImport = (load)=>{
import('./component.js').
then((Module)=>{
load[0] = Module;
});};
callImport(Result);
setTimeout(()=> console.log(Result[0]),10);
Here i used setTimeout as await to prevent print Result before promise execution finish. Here is Codepen sample without setTimeout : https://codepen.io/MNSY22/pen/NWPdvxd
Just chain another then
call, since shortAfterLongFunc
returns new promise you can further work with it:
longFunc().then(shortAfterLongFunc).then(function(data) {
console.log('all is complted', data);
});