Skip to content

Commit 05446a9

Browse files
committed
adjusting setProps to use a window.dash_stores array which builds a list of stores that the app has
1 parent 78ccd87 commit 05446a9

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

dash/dash-renderer/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {DashRenderer} from './DashRenderer';
2+
import './utils/setProps';
23

34
// make DashRenderer globally available
45
window.DashRenderer = DashRenderer;

dash/dash-renderer/src/store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import loadingMap from './observers/loadingMap';
1515
import prioritizedCallbacks from './observers/prioritizedCallbacks';
1616
import requestedCallbacks from './observers/requestedCallbacks';
1717
import storedCallbacks from './observers/storedCallbacks';
18-
import setProps from './observers/setProps';
1918

2019
export interface IStoreState {
2120
callbacks: ICallbacksState;
@@ -52,12 +51,13 @@ export default class RendererStore {
5251
observe(executingCallbacks);
5352
observe(executedCallbacks);
5453
observe(storedCallbacks);
55-
observe(setProps);
5654
});
5755

5856
private createAppStore = (reducer: any, middleware: any) => {
5957
this.__store = createStore(reducer, middleware);
6058
this.storeObserver.setStore(this.__store);
59+
const ds = (window.dash_stores = window.dash_stores || []);
60+
ds.push(this.__store);
6161
this.setObservers();
6262
};
6363

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import {updateProps, notifyObservers} from '../actions/index';
2+
import {getPath} from '../actions/paths';
23

3-
const makeSetProps = ({dispatch, getState}) => {
4-
const setProps = (updates: {}) => {
4+
const setProps = (updates: {}) => {
5+
const ds = (window.dash_stores = window.dash_stores || []);
6+
for (let y = 0; y < ds.length; y++) {
7+
const {dispatch, getState} = ds[y];
58
const {paths} = getState();
69
Object.entries(updates).forEach(([componentId, props]) => {
7-
const componentPath = paths.strs[componentId];
10+
const componentPath = getPath(paths, componentId);
811
dispatch(
912
updateProps({
1013
props,
@@ -13,10 +16,8 @@ const makeSetProps = ({dispatch, getState}) => {
1316
);
1417
dispatch(notifyObservers({id: componentId, props}));
1518
});
16-
};
17-
18-
window.dash_clientside = window.dash_clientside || {};
19-
window.dash_clientside['setProps'] = setProps;
19+
}
2020
};
2121

22-
export default makeSetProps;
22+
const dc = (window.dash_clientside = window.dash_clientside || {});
23+
dc['setProps'] = setProps;

0 commit comments

Comments
 (0)