UNPKG

832 BJavaScriptView Raw
1/**
2 * Array of callbacks to invoke when a new context is created
3 */
4const notifyNewContext = [];
5/**
6 * Used internally to setup a new Context
7 */
8export function onContextInit(cb) {
9 notifyNewContext.push(cb);
10}
11/**
12 * Invoke any classes which need to also be initialized when a new context is created.
13 */
14export function initializeContext(ctx) {
15 // add any additional modules
16 notifyNewContext.forEach((cb) => cb(ctx));
17}
18/**
19 * Array of callbacks to invoke when a new context is closed
20 */
21const notifyCloseContext = [];
22/**
23 * Used internally to tear down a Context
24 */
25export function onContextClose(cb) {
26 notifyCloseContext.push(cb);
27}
28export function closeContext(ctx) {
29 // remove any additional modules
30 notifyCloseContext.forEach((cb) => cb(ctx));
31}
32//# sourceMappingURL=ContextInitialization.js.map
\No newline at end of file