Decorators that works on instance but not specified on method / property
Sometime we need a decorator to work on instance (not class itself), but we do not have any method / property for it, these usually comes with metadata additions:
function foo(value) {
return function (target) [
(target.meta || (target.meta = {})).foo = value;
}
}
Such decorators only add additional metadata so it can be used in runtime. I know it could be archived with class decorator and class inheritance but it's really not that intuitive.
I propose decorators could be used on constructor, which works when an instance is created just like method decorators, but constructor decorators does not descriptor argument, and the key argument is "constructor"
Possible duplicate: https://github.com/wycats/javascript-decorators/issues/13
:+1: I'll be also interested in decorators on POJOs to be able to enhance more than one method with a decorator.