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

Class RendererStore

dash/dash-renderer/src/store.ts:30–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30export default class RendererStore {
31 constructor() {
32 this.__store = this.initializeStore();
33 }
34
35 private __store: Store<IStoreState>;
36 public get store(): Store<IStoreState> {
37 return this.__store;
38 }
39
40 private readonly storeObserver = new StoreObserver<IStoreState>();
41
42 private setObservers = once(() => {
43 const observe = this.storeObserver.observe;
44
45 // FIXME Remove observer pattern and refactor to standard reducers/actions/selectors.
46 observe(documentTitle);
47 observe(isLoading);
48 observe(requestedCallbacks);
49 observe(prioritizedCallbacks);
50 observe(executingCallbacks);
51 observe(executedCallbacks);
52 observe(storedCallbacks);
53 });
54
55 private createAppStore = (reducer: any, middleware: any) => {
56 this.__store = createStore(reducer, middleware);
57 this.storeObserver.setStore(this.__store);
58 const ds = ((window as any).dash_stores =
59 (window as any).dash_stores || []);
60 if (!ds.includes(this.__store)) {
61 ds.push(this.__store);
62 }
63 this.setObservers();
64 };
65
66 /**
67 * Initialize a Redux store with thunk, plus logging (only in development mode) middleware
68 *
69 * @param {bool} reset: discard any previous store
70 *
71 * @returns {Store<GenericStoreEnhancer>}
72 * An initialized redux store with middleware and possible hot reloading of reducers
73 */
74 initializeStore = (reset?: boolean): Store<IStoreState> => {
75 if (this.__store && !reset) {
76 return this.__store;
77 }
78
79 const reducer = createReducer();
80
81 // eslint-disable-next-line no-process-env
82 if (process.env.NODE_ENV === 'production') {
83 this.createAppStore(reducer, applyMiddleware(thunk));
84 } else {
85 // only attach logger to middleware in non-production mode
86 const reduxDTEC = (window as any)
87 .__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;

Callers

nothing calls this directly

Calls 2

createReducerFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…