summaryrefslogtreecommitdiff
path: root/ofborg/ofborg-viewer/src/index.js
blob: e2b8683f9e927463838ef69ba50f2ce4303cb69e (plain)
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
38
39
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();