Closed ylc395 closed 2 years ago
Have this same issue. Have to manually bind on every root resolve. Any chance for a fix/alternative solution to this?
the best way is to use arrow function instead since it has lexical scoping
doing this
const {method1, method2} = container.resolve(SomeService);
is the same as
const {method1, method2} = new SomeService();
container shouldn't bind methods
if you really need bind methods, you can use something like this https://www.npmjs.com/package/autobind-decorator or use arrow functions
This is a common pattern in code base:
However,
method1
/method2
has wrongthis
when calling them.