mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-29 04:53:10 +00:00
22 lines
635 B
TypeScript
22 lines
635 B
TypeScript
///////////////////////////////////////////////////////////////////////////
|
|
// INITIALIZING NEW CONTEXT
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
type Context = import("./Context").Context;
|
|
|
|
/**
|
|
* Array of callbacks to invoke when a new context is created
|
|
*/
|
|
const notifyNewContext: Array<(ctx: Context) => void> = [];
|
|
|
|
/**
|
|
* Used internally to setup a new Context
|
|
*/
|
|
export function onContextInit(cb: (ctx: Context) => void): void {
|
|
notifyNewContext.push(cb);
|
|
}
|
|
|
|
export function initializeContext(ctx: Context): void {
|
|
// add any additional modules
|
|
notifyNewContext.forEach(cb => cb(ctx));
|
|
}
|