forked from reactive-python/reactpy-django
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (33 loc) · 902 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { mountLayoutWithWebSocket } from "idom-client-react";
// Set up a websocket at the base endpoint
let LOCATION = window.location;
let WS_PROTOCOL = "";
if (LOCATION.protocol == "https:") {
WS_PROTOCOL = "wss://";
} else {
WS_PROTOCOL = "ws://";
}
let WS_ENDPOINT_URL = WS_PROTOCOL + LOCATION.host + "/";
export function mountViewToElement(
mountPoint,
idomWebsocketUrl,
idomWebModulesUrl,
maxReconnectTimeout,
viewId,
queryParams
) {
const fullWebsocketUrl =
WS_ENDPOINT_URL + idomWebsocketUrl + viewId + "/?" + queryParams;
const fullWebModulesUrl = LOCATION.origin + "/" + idomWebModulesUrl;
const loadImportSource = (source, sourceType) => {
return import(
sourceType == "NAME" ? `${fullWebModulesUrl}${source}` : source
);
};
mountLayoutWithWebSocket(
mountPoint,
fullWebsocketUrl,
loadImportSource,
maxReconnectTimeout
);
}