MCPcopy
hub / github.com/HumanSignal/label-studio / resolveAsyncComponent

Function resolveAsyncComponent

docs/themes/htx/source/js/vue.js:2213–2301  ·  view source on GitHub ↗
(factory, baseCtor, context)

Source from the content-addressed store, hash-verified

2211 }
2212
2213 function resolveAsyncComponent(factory, baseCtor, context) {
2214 if (isTrue(factory.error) && isDef(factory.errorComp)) {
2215 return factory.errorComp;
2216 }
2217
2218 if (isDef(factory.resolved)) {
2219 return factory.resolved;
2220 }
2221
2222 if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
2223 return factory.loadingComp;
2224 }
2225
2226 if (isDef(factory.contexts)) {
2227 // already pending
2228 factory.contexts.push(context);
2229 } else {
2230 var contexts = (factory.contexts = [context]);
2231 var sync = true;
2232
2233 var forceRender = function() {
2234 for (var i = 0, l = contexts.length; i < l; i++) {
2235 contexts[i].$forceUpdate();
2236 }
2237 };
2238
2239 var resolve = once(function(res) {
2240 // cache resolved
2241 factory.resolved = ensureCtor(res, baseCtor);
2242 // invoke callbacks only if this is not a synchronous resolve
2243 // (async resolves are shimmed as synchronous during SSR)
2244 if (!sync) {
2245 forceRender();
2246 }
2247 });
2248
2249 var reject = once(function(reason) {
2250 "development" !== "production" &&
2251 warn("Failed to resolve async component: " + String(factory) + (reason ? "\nReason: " + reason : ""));
2252 if (isDef(factory.errorComp)) {
2253 factory.error = true;
2254 forceRender();
2255 }
2256 });
2257
2258 var res = factory(resolve, reject);
2259
2260 if (isObject(res)) {
2261 if (typeof res.then === "function") {
2262 // () => Promise
2263 if (isUndef(factory.resolved)) {
2264 res.then(resolve, reject);
2265 }
2266 } else if (isDef(res.component) && typeof res.component.then === "function") {
2267 res.component.then(resolve, reject);
2268
2269 if (isDef(res.error)) {
2270 factory.errorComp = ensureCtor(res.error, baseCtor);

Callers 1

createComponentFunction · 0.85

Calls 8

isTrueFunction · 0.85
isDefFunction · 0.85
onceFunction · 0.85
ensureCtorFunction · 0.85
forceRenderFunction · 0.85
isObjectFunction · 0.85
isUndefFunction · 0.85
setTimeoutFunction · 0.85

Tested by

no test coverage detected