core-decorators icon indicating copy to clipboard operation
core-decorators copied to clipboard

Autobind decorator

Open barmaglot92 opened this issue 8 years ago • 2 comments

Hi, why you didn`t use .bind for autobind decorator. So why you use WeekMap and so complicated realization?

barmaglot92 avatar Sep 15 '17 07:09 barmaglot92

It does indeed use .bind if it's available.

Creating a truly universal autobind decorator is harder than one thinks. There are numerous edge cases that have been found over the years, one of which is when you autobind a method that calls the same method on the super prototype and that method was also had used autobind

I try to include brief descriptions in the online comments about why things are done

// Autobound method calling super.sameMethod() which is also autobound and so on.

jayphelps avatar Sep 15 '17 14:09 jayphelps

More insight into the super.sameMethod() problem needing WeakMap #20 and #21

jayphelps avatar Sep 15 '17 19:09 jayphelps