Skip to content

Commit 7eb975d

Browse files
committed
exposing clientSide_setProps by utilizing an observer
1 parent 39c479b commit 7eb975d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
import {IStoreState} from '../store';
3+
import {updateProps, notifyObservers} from '../actions/index'
4+
5+
const observer: IStoreObserverDefinition<IStoreState> = {
6+
observer: ({dispatch, getState}) => {
7+
const clientSide_setProps = (updates: {}) => {
8+
const {paths} = getState()
9+
Object.entries(updates).forEach(([componentId, props]) => {
10+
const componentPath = paths.strs[componentId];
11+
dispatch(
12+
updateProps({
13+
props,
14+
itempath: componentPath
15+
})
16+
);
17+
dispatch(
18+
notifyObservers({id: componentId, props})
19+
);
20+
});
21+
}
22+
23+
24+
window.dash_clientside = window.dash_clientside || {};
25+
window.dash_clientside['clientSide_setProps'] = clientSide_setProps
26+
},
27+
inputs: ['callbacks.executed']
28+
};
29+
30+
export default observer;

dash/dash-renderer/src/store.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ 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 clientSide_setProps from './observers/clientSide_setProps';
1819

1920
export interface IStoreState {
2021
callbacks: ICallbacksState;
@@ -51,6 +52,7 @@ export default class RendererStore {
5152
observe(executingCallbacks);
5253
observe(executedCallbacks);
5354
observe(storedCallbacks);
55+
observe(clientSide_setProps);
5456
});
5557

5658
private createAppStore = (reducer: any, middleware: any) => {

0 commit comments

Comments
 (0)