
import store from '@/state/store';

export function lazyLoadWatcher(importCallback: () => Promise<any>) {
  store.commit('mfeContainer/setMfeModuleLoading', true);

  // return importCallback().then(module => {
  //   store.commit('mfeContainer/setMfeModuleLoading', false);
  //   return module;
  // });

  return Promise.allSettled([
    new Promise(resolve => setTimeout(resolve, 700)),
    importCallback(),
  ]).then(([_, module]) => {
    if (module.status === 'fulfilled') {
      store.commit('mfeContainer/setMfeModuleLoading', false);
      return module.value;
    }
  })
  
}
