MCPcopy
hub / github.com/fanmingming/live / resolveAsyncComponent

Function resolveAsyncComponent

m3u8/vue.js:3611–3731  ·  view source on GitHub ↗
(
    factory,
    baseCtor
  )

Source from the content-addressed store, hash-verified

3609 }
3610
3611 function resolveAsyncComponent (
3612 factory,
3613 baseCtor
3614 ) {
3615 if (isTrue(factory.error) && isDef(factory.errorComp)) {
3616 return factory.errorComp
3617 }
3618
3619 if (isDef(factory.resolved)) {
3620 return factory.resolved
3621 }
3622
3623 var owner = currentRenderingInstance;
3624 if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
3625 // already pending
3626 factory.owners.push(owner);
3627 }
3628
3629 if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
3630 return factory.loadingComp
3631 }
3632
3633 if (owner && !isDef(factory.owners)) {
3634 var owners = factory.owners = [owner];
3635 var sync = true;
3636 var timerLoading = null;
3637 var timerTimeout = null
3638
3639 ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
3640
3641 var forceRender = function (renderCompleted) {
3642 for (var i = 0, l = owners.length; i < l; i++) {
3643 (owners[i]).$forceUpdate();
3644 }
3645
3646 if (renderCompleted) {
3647 owners.length = 0;
3648 if (timerLoading !== null) {
3649 clearTimeout(timerLoading);
3650 timerLoading = null;
3651 }
3652 if (timerTimeout !== null) {
3653 clearTimeout(timerTimeout);
3654 timerTimeout = null;
3655 }
3656 }
3657 };
3658
3659 var resolve = once(function (res) {
3660 // cache resolved
3661 factory.resolved = ensureCtor(res, baseCtor);
3662 // invoke callbacks only if this is not a synchronous resolve
3663 // (async resolves are shimmed as synchronous during SSR)
3664 if (!sync) {
3665 forceRender(true);
3666 } else {
3667 owners.length = 0;
3668 }

Callers 1

createComponentFunction · 0.85

Calls 10

isTrueFunction · 0.85
isDefFunction · 0.85
onceFunction · 0.85
ensureCtorFunction · 0.85
forceRenderFunction · 0.85
warnFunction · 0.85
isObjectFunction · 0.85
isPromiseFunction · 0.85
isUndefFunction · 0.85
removeFunction · 0.70

Tested by

no test coverage detected