File tree 4 files changed +33
-23
lines changed
4 files changed +33
-23
lines changed Original file line number Diff line number Diff line change 10
10
IDOM_BASE_URL = getattr (settings , "IDOM_BASE_URL" , "_idom/" )
11
11
IDOM_WEBSOCKET_URL = IDOM_BASE_URL + "websocket/"
12
12
IDOM_WEB_MODULES_URL = IDOM_BASE_URL + "web_module/"
13
+ IDOM_WS_RECONNECT = getattr (settings , "IDOM_WS_RECONNECT" , True )
13
14
14
15
_CACHES = getattr (settings , "CACHES" , {})
15
16
if _CACHES :
Original file line number Diff line number Diff line change 7
7
mountPoint ,
8
8
"{{ idom_websocket_url }}" ,
9
9
"{{ idom_web_modules_url }}" ,
10
+ parseInt ( "{% if idom_ws_reconnect %}604800{% else %}0{% endif %}" ) ,
10
11
"{{ idom_component_id }}" ,
11
12
"{{ idom_component_params }}"
12
13
) ;
13
- </ script >
14
+ </ script >
Original file line number Diff line number Diff line change 10
10
IDOM_REGISTERED_COMPONENTS ,
11
11
IDOM_WEB_MODULES_URL ,
12
12
IDOM_WEBSOCKET_URL ,
13
+ IDOM_WS_RECONNECT ,
13
14
)
14
15
15
16
@@ -27,6 +28,7 @@ def idom_component(_component_id_, **kwargs):
27
28
"class" : class_ ,
28
29
"idom_websocket_url" : IDOM_WEBSOCKET_URL ,
29
30
"idom_web_modules_url" : IDOM_WEB_MODULES_URL ,
31
+ "idom_ws_reconnect" : IDOM_WS_RECONNECT ,
30
32
"idom_mount_uuid" : uuid4 ().hex ,
31
33
"idom_component_id" : _component_id_ ,
32
34
"idom_component_params" : urlencode ({"kwargs" : json_kwargs }),
@@ -36,12 +38,12 @@ def idom_component(_component_id_, **kwargs):
36
38
def _register_component (full_component_name : str ) -> None :
37
39
module_name , component_name = full_component_name .rsplit ("." , 1 )
38
40
39
- try :
40
- module = import_module (module_name )
41
- except ImportError as error :
42
- raise RuntimeError (
43
- f"Failed to import { module_name !r} while loading { component_name !r} "
44
- ) from error
41
+ try :
42
+ module = import_module (module_name )
43
+ except ImportError as error :
44
+ raise RuntimeError (
45
+ f"Failed to import { module_name !r} while loading { component_name !r} "
46
+ ) from error
45
47
46
48
try :
47
49
component = getattr (module , component_name )
Original file line number Diff line number Diff line change @@ -4,28 +4,34 @@ import { mountLayoutWithWebSocket } from "idom-client-react";
4
4
let LOCATION = window . location ;
5
5
let WS_PROTOCOL = "" ;
6
6
if ( LOCATION . protocol == "https:" ) {
7
- WS_PROTOCOL = "wss://" ;
7
+ WS_PROTOCOL = "wss://" ;
8
8
} else {
9
- WS_PROTOCOL = "ws://" ;
9
+ WS_PROTOCOL = "ws://" ;
10
10
}
11
11
let WS_ENDPOINT_URL = WS_PROTOCOL + LOCATION . host + "/" ;
12
12
13
13
export function mountViewToElement (
14
- mountPoint ,
15
- idomWebsocketUrl ,
16
- idomWebModulesUrl ,
17
- viewId ,
18
- queryParams
14
+ mountPoint ,
15
+ idomWebsocketUrl ,
16
+ idomWebModulesUrl ,
17
+ maxReconnectTimeout ,
18
+ viewId ,
19
+ queryParams
19
20
) {
20
- const fullWebsocketUrl =
21
- WS_ENDPOINT_URL + idomWebsocketUrl + viewId + "/?" + queryParams ;
21
+ const fullWebsocketUrl =
22
+ WS_ENDPOINT_URL + idomWebsocketUrl + viewId + "/?" + queryParams ;
22
23
23
- const fullWebModulesUrl = LOCATION . origin + "/" + idomWebModulesUrl
24
- const loadImportSource = ( source , sourceType ) => {
25
- return import (
26
- sourceType == "NAME" ? `${ fullWebModulesUrl } ${ source } ` : source
27
- ) ;
28
- } ;
24
+ const fullWebModulesUrl = LOCATION . origin + "/" + idomWebModulesUrl ;
25
+ const loadImportSource = ( source , sourceType ) => {
26
+ return import (
27
+ sourceType == "NAME" ? `${ fullWebModulesUrl } ${ source } ` : source
28
+ ) ;
29
+ } ;
29
30
30
- mountLayoutWithWebSocket ( mountPoint , fullWebsocketUrl , loadImportSource ) ;
31
+ mountLayoutWithWebSocket (
32
+ mountPoint ,
33
+ fullWebsocketUrl ,
34
+ loadImportSource ,
35
+ maxReconnectTimeout
36
+ ) ;
31
37
}
You can’t perform that action at this time.
0 commit comments