MCPcopy Index your code
hub / github.com/plotly/dash / asyncDecorator

Function asyncDecorator

@plotly/dash-component-plugins/src/dynamicImport.js:3–28  ·  view source on GitHub ↗
(target, promise)

Source from the content-addressed store, hash-verified

1import { lazy } from 'react';
2
3export const asyncDecorator = (target, promise) => {
4 let resolve;
5 const isReady = new Promise(r => {
6 resolve = r;
7 });
8
9 const state = {
10 isReady,
11 get: lazy(() => {
12 return Promise.resolve(promise()).then(res => {
13 setTimeout(async () => {
14 await resolve(true);
15 state.isReady = true;
16 }, 0);
17
18 return res;
19 });
20 }),
21 };
22
23 Object.defineProperty(target, '_dashprivate_isLazyComponentReady', {
24 get: () => state.isReady
25 });
26
27 return state.get;
28};
29
30export const inheritAsyncDecorator = (target, source) => {
31 Object.defineProperty(target, '_dashprivate_isLazyComponentReady', {

Callers 4

Graph.react.jsFile · 0.90
Markdown.react.jsFile · 0.90
DataTable.jsFile · 0.90
AsyncComponent.jsFile · 0.90

Calls 1

lazyFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…