MCPcopy Create free account
hub / github.com/TruthHun/BookStack / resolveAsyncComponent

Function resolveAsyncComponent

static/vuejs/vue.runtime.common.js:3116–3162  ·  view source on GitHub ↗
(
  factory,
  baseCtor,
  cb
)

Source from the content-addressed store, hash-verified

3114}
3115
3116function resolveAsyncComponent (
3117 factory,
3118 baseCtor,
3119 cb
3120) {
3121 if (factory.requested) {
3122 // pool callbacks
3123 factory.pendingCallbacks.push(cb);
3124 } else {
3125 factory.requested = true;
3126 var cbs = factory.pendingCallbacks = [cb];
3127 var sync = true;
3128
3129 var resolve = function (res) {
3130 if (isObject(res)) {
3131 res = baseCtor.extend(res);
3132 }
3133 // cache resolved
3134 factory.resolved = res;
3135 // invoke callbacks only if this is not a synchronous resolve
3136 // (async resolves are shimmed as synchronous during SSR)
3137 if (!sync) {
3138 for (var i = 0, l = cbs.length; i < l; i++) {
3139 cbs[i](res);
3140 }
3141 }
3142 };
3143
3144 var reject = function (reason) {
3145 process.env.NODE_ENV !== 'production' && warn(
3146 "Failed to resolve async component: " + (String(factory)) +
3147 (reason ? ("\nReason: " + reason) : '')
3148 );
3149 };
3150
3151 var res = factory(resolve, reject);
3152
3153 // handle promise
3154 if (res && typeof res.then === 'function' && !factory.resolved) {
3155 res.then(resolve, reject);
3156 }
3157
3158 sync = false;
3159 // return in case resolved synchronously
3160 return factory.resolved
3161 }
3162}
3163
3164function extractProps (data, Ctor, tag) {
3165 // we are only extracting raw values here.

Callers 1

createComponentFunction · 0.70

Calls 1

factoryFunction · 0.50

Tested by

no test coverage detected