Can I pass a context to an augmented function?
While this library provides a way to use a context, it's somehow a footgun to enable multiple contexts for a single augmented stack, so by default you cannot use augmented.call(ctx) or augmented.apply(ctx, []), 'cause no context whatsoever is passed along.
If by any chance you've read, and understood, the [related blog post](https://medium.com/@WebReflection/demystifying-hooks-f55ad885609f), you'd realize a single augmented function is indeed not good for prototypes or shared methods, as one context could interfere with any other previous context that used that method before.
```js
// WRONG: this is a very bad idea, as any MyComp instance
// could potentially interfere with other instances
MyComp.prototype.doThings = augmentor(doThings);
// GOOD: this is how you'd do it 👍
class MyComp {
constructor() {
const {doThings} = this;
// augment a bound method/function per each instance
this.doThings = augmentor(doThings.bind(this));
}
doThings() {
// where actually you do hooky-things
}
}
```
That being said, if you *really* want to share a context within a single augmented function, meaning that you understand, and know, what you are doing, you can
use the contextual utility provided by this library.
```js
import {contextual} from 'augmentor';
const textInjector = contextual(function (text) {
this.textContent = text;
});
textInjector.call(div, 'hello');
textInjector.call(p, 'there!');
```
Please bear in mind that _contextualized_ functions effects will also refer to the previous context, not necessarily the current one, so that you see it's very easy to create troubles sharing, accepting, or passing, multiple contexts to the same augmented stack.
As summary, augmentor(method.bind(context)) is the best way to use a context within an augmented function, but contextual can help covering other weird edge cases too.