summaryrefslogtreecommitdiff
path: root/ofborg/ofborg-viewer/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'ofborg/ofborg-viewer/src/index.js')
-rw-r--r--ofborg/ofborg-viewer/src/index.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/ofborg/ofborg-viewer/src/index.js b/ofborg/ofborg-viewer/src/index.js
new file mode 100644
index 0000000000..e2b8683f9e
--- /dev/null
+++ b/ofborg/ofborg-viewer/src/index.js
@@ -0,0 +1,40 @@
+import App from "./app";
+import WELL_KNOWN from "./config";
+
+/**
+ * Entry-point of the application.
+ *
+ * If any polyfilling is needed, do it here.
+ * Then, start the app.
+ */
+
+// Fetch compat.
+{
+ const FETCH_MISSING = "fetch is required for this app to work properly.";
+
+ /**
+ * Acts mostly like a promise.
+ */
+ const pseudo_promise = function() {
+ return {
+ then: () => pseudo_promise(),
+ catch: (fn) => fn(new Error(FETCH_MISSING)),
+ };
+ };
+
+ /**
+ * Replaces fetch when fetch is missing.
+ */
+ const pseudo_fetch = function() { // eslint-disable-line
+ return pseudo_promise();
+ };
+
+ // Ensures calls to `fetch` don't crash the app.
+ if (!window.fetch) {
+ console.warn(FETCH_MISSING); // eslint-disable-line
+ window.fetch = pseudo_fetch; // eslint-disable-line
+ }
+}
+
+// Starts the app.
+window.APP = new App();