1
- import { concat , path } from 'ramda' ;
1
+ import { path } from 'ramda' ;
2
+
2
3
import { updateProps , notifyObservers } from '../actions/index' ;
3
4
import { getPath } from '../actions/paths' ;
4
5
6
+ function getStores ( ) {
7
+ const stores = ( ( window as any ) . dash_stores =
8
+ ( window as any ) . dash_stores || [ ] ) ;
9
+ return stores ;
10
+ }
11
+
5
12
/**
6
13
* Set the props of a dash component by id or path.
7
14
*
@@ -12,8 +19,7 @@ function set_props(
12
19
idOrPath : string | object | string [ ] ,
13
20
props : { [ k : string ] : any }
14
21
) {
15
- const ds = ( ( window as any ) . dash_stores =
16
- ( window as any ) . dash_stores || [ ] ) ;
22
+ const ds = getStores ( ) ;
17
23
for ( let y = 0 ; y < ds . length ; y ++ ) {
18
24
const { dispatch, getState} = ds [ y ] ;
19
25
let componentPath ;
@@ -64,12 +70,8 @@ const clean_url = (url: string, fallback = 'about:blank') => {
64
70
* @param propPath Additional key to get the property instead of plain props.
65
71
* @returns
66
72
*/
67
- function get_props (
68
- componentPathOrId : string [ ] | string ,
69
- ...propPath : string [ ]
70
- ) : any {
71
- const ds = ( ( window as any ) . dash_stores =
72
- ( window as any ) . dash_stores || [ ] ) ;
73
+ function get_layout ( componentPathOrId : string [ ] | string ) : any {
74
+ const ds = getStores ( ) ;
73
75
for ( let y = 0 ; y < ds . length ; y ++ ) {
74
76
const { paths, layout} = ds [ y ] . getState ( ) ;
75
77
let componentPath ;
@@ -78,10 +80,7 @@ function get_props(
78
80
} else {
79
81
componentPath = componentPathOrId ;
80
82
}
81
- const props = path (
82
- concat ( componentPath , [ 'props' , ...propPath ] ) ,
83
- layout
84
- ) ;
83
+ const props = path ( componentPath , layout ) ;
85
84
if ( props !== undefined ) {
86
85
return props ;
87
86
}
@@ -92,4 +91,4 @@ const dc = ((window as any).dash_clientside =
92
91
( window as any ) . dash_clientside || { } ) ;
93
92
dc [ 'set_props' ] = set_props ;
94
93
dc [ 'clean_url' ] = dc [ 'clean_url' ] === undefined ? clean_url : dc [ 'clean_url' ] ;
95
- dc [ 'get_props ' ] = get_props ;
94
+ dc [ 'get_layout ' ] = get_layout ;
0 commit comments