diff --git a/src/api/context.ts b/src/api/context.ts index 34a1b806..292f50ea 100644 --- a/src/api/context.ts +++ b/src/api/context.ts @@ -78,6 +78,7 @@ export class ContextAPI { /** * Bind a context to a target function or event emitter + * @deprecated in 0.x, will be removed in 1.x * * @param target function or event emitter to bind * @param context context to bind to the event emitter or function. Defaults to the currently active context @@ -86,6 +87,16 @@ export class ContextAPI { return this._getContextManager().bind(target, context); } + /** + * Bind a context to a target function or event emitter + * + * @param context context to bind to the event emitter or function. Defaults to the currently active context + * @param target function or event emitter to bind + */ + public bind(context: Context = this.active(), target: T): T { + return this._getContextManager().bind(target, context); + } + private _getContextManager(): ContextManager { return getGlobal(API_NAME) || NOOP_CONTEXT_MANAGER; }