UNPKG

framework7

Version:

Full featured mobile HTML framework for building iOS & Android apps

24 lines (23 loc) 662 B
export default function (router, asyncComponent, resolve, reject) { function resolvePromise(componentPromise) { componentPromise .then((c) => { // eslint-disable-next-line resolve({ component: c.default || c._default || c }); }) .catch((err) => { reject(); throw new Error(err); }); } if (asyncComponent instanceof Promise) { resolvePromise(asyncComponent); return; } const asyncComponentResult = asyncComponent.call(router); if (asyncComponentResult instanceof Promise) { resolvePromise(asyncComponentResult); } else { resolve({ component: asyncComponentResult }); } }