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

Commit

Permalink
feat: remove deprecated bind, short circuit if context === undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
rauno56 committed May 21, 2021
1 parent cb2cbbe commit 8e4bbd1
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/api/context.ts
Expand Up @@ -76,24 +76,16 @@ export class ContextAPI {
return this._getContextManager().with(context, fn, thisArg, ...args);
}

/**
* 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
*/
public bind<T>(target: T, context: Context = this.active()): T {
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 {
public bind<T>(context: Context, target: T): T {
if (context === undefined) {
return target;
}
return this._getContextManager().bind(target, context);
}

Expand Down

0 comments on commit 8e4bbd1

Please sign in to comment.