-
-
Notifications
You must be signed in to change notification settings - Fork 829
/
app.ts
31 lines (28 loc) · 783 Bytes
/
app.ts
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
import type Application from './Application';
// Used to fix typings
const w = window as any;
/**
* Proxy app. Common JS is run first, at which point `window.app` is not
* set as this is done by the namespaced JS.
*
* When the corrent value is set, this code would retain the reference to
* the original invalid value.
*
* By using a proxy, we can ensure that our `window.app` value is always
* up-to-date with the latest reference.
*/
const appProxy = new Proxy(
{},
{
get(_, properties) {
return Reflect.get(w.app, properties, w.app);
},
set(_, properties, value) {
return Reflect.set(w.app, properties, value, w.app);
},
}
);
/**
* The instance of Application within the common namespace.
*/
export default appProxy as Application;