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

Function resolveAsyncComponent

static/vuejs/vue.esm.js:3118–3164  ·  view source on GitHub ↗
(
  factory,
  baseCtor,
  cb
)

Source from the content-addressed store, hash-verified

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

Callers 1

createComponentFunction · 0.70

Calls 1

factoryFunction · 0.50

Tested by

no test coverage detected