Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorators that works on instance but not specified on method / property #21

Open
otakustay opened this issue May 31, 2015 · 2 comments

Comments

@otakustay
Copy link

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"

@megawac
Copy link

megawac commented May 31, 2015

Possible duplicate: #13

@troch
Copy link

troch commented Jul 10, 2015

👍 I'll be also interested in decorators on POJOs to be able to enhance more than one method with a decorator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants