Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
feat: unify signatures of with and bind
Browse files Browse the repository at this point in the history
  • Loading branch information
rauno56 committed May 21, 2021
1 parent 77b8c34 commit cb2cbbe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/api/context.ts
Expand Up @@ -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
Expand All @@ -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<T>(context: Context = this.active(), target: T): T {
return this._getContextManager().bind(target, context);
}

private _getContextManager(): ContextManager {
return getGlobal(API_NAME) || NOOP_CONTEXT_MANAGER;
}
Expand Down

0 comments on commit cb2cbbe

Please sign in to comment.