Restrict the usage of method decorators

I have a decorator for methods that I want it to be used only with async methods. This is an example of usage: class A { @deco() // This should work. public async works() { } @deco() // This should fail. public fails() { } } I tried to def...
more »

2017-09-18 15:09 (1) Answers

Understanding how class decorators work in Python

I've got a problem with understanding how class decorators in Python work. In this case I want to write a decorator that counts how many times recursive function (searching for Greatest Common Divisor) was called. I have a decorator: class TrackCal...
more »

2017-05-21 14:05 (1) Answers

Using Lists Instead of Decorator Pattern?

A Decorator Pattern use case from "Head First: Design Patterns" book made me have this question. I'll try to write it down: It's a coffee shop system with some coffees and a lot of condiments you can put in them (for an extra cost), you need to...
more »

2017-04-23 00:04 (3) Answers

Aurelia Validation: Decorator API deprecated?

I see from early alpha documentation that the versions of Aurelia validation that were based on validatejs supported decorators like @require. Has this functionality gone away in the 1.0 product? I see no mention in the docs, and the decorators don't...
more »

2017-03-22 15:03 (1) Answers

Using classes as method decorators

While there are plenty of resources about using classes as decorators, I haven't been able to find any that deal with the problem of decorating methods. The goal of this question is to fix that. I will post my own solution, but of course everyone els...
more »

2017-03-08 12:03 (1) Answers

Java Class decorate itself

I think I kind of reinvent caching in Java but have a point I don't get further. In case the answer is anywhere on Stackoverflow for this issue I might had not understood it when searching or didn't understand the required complexity and searched fo...
more »

2017-01-17 12:01 (1) Answers

JavaScript Decorator on Class constructor

I'm trying to add some properties in class instances (like a Plugin system). For that, I followed this example to do that with a Class Decorator: function testDecorator(target:any) { // save a reference to the original constructor var origin...
more »

2016-12-19 11:12 (0) Answers

Function Attributes - Scope

So I have this code: def collect_input(func): """ A decorator which adds an all_input attribute to the wrapped function. This attribute collects any input passed to the function. """ def wrapper(*args, **kwargs): wrapper....
more »

2016-12-01 11:12 (2) Answers

Bind this when using method decorators in React

How to bind this with transform-decorators-legacy Babel plugin? For example I have some simple decorator. Decorator works, but this is undefined on component's method. fucntion myDecorator(target, name, descriptor) { var oldValue = descriptor.va...
more »

2016-11-28 01:11 (2) Answers

Override constructor with an class decorator?

How can I override a constructor with an ES7 class decorator? For example, I'd like to have something like: @injectAttributes({ foo: 42 }) class Bar { constructor() { console.log(this.foo); } } Where the injectAttributes decorator will in...
more »

2016-11-25 01:11 (1) Answers

reactjs mobx without decorators not working

I am trying to incorporate mobx with react. Since I spawned my application using create-react-app, I can't use decorators given by mobx. Given that we can use mobx without decorators as per this documentation: https://mobxjs.github.io/mobx/best/deco...
more »

2016-11-08 09:11 (1) Answers

Python - dill: Can't pickle decorated class

I have the following code, which decorates the class: import dill from collections import namedtuple from multiprocessing import Process def proxified(to_be_proxied): b = namedtuple('d', []) class Proxy(to_be_proxied, b): pass ...
more »

2016-10-13 18:10 (0) Answers

Redux, Provider and decorators

I'm new with redux, and i'm trying to build my app with it. I created reducers file, the combine reducers file, the components, the actions, etc But when i start my server i get Unexpected token where @connect() is called. Let see my code: Main.js ...
more »

2016-10-05 18:10 (1) Answers