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 #8

Closed
buschtoens opened this issue Aug 6, 2017 · 2 comments
Closed

Decorators #8

buschtoens opened this issue Aug 6, 2017 · 2 comments

Comments

@buschtoens
Copy link
Owner

As a sequel to #7, we can also provide decorators:

import routeTask from 'ember-route-task-helper/utils/route-task-decorator'; 
import curry from 'ember-route-task-helper/utils/curry-decorator'; 

export default class extends Component {
  @routeTask taskName; // name is determined via key reflection

  @routeTask('fooTask') otherTask; // name is explicitly provided

  // Since `@routeTask` already takes an optional name,
  // currying is performed using an extra decorator.
  @curry('Freddie', 'Morecurry')
  @routeTask('barTask') curriedTask;

  // Alternatively task could be curried via the descriptor value,
  // but I don't think that is really explicit or easy to understand.
  @routeTask('barTask') curriedTask = ['Freddie', 'Morecurry'];
}

Also, the @curry decorator can be re-used with regular tasks. 🙌

@buschtoens
Copy link
Owner Author

Waiting for ember-decorators/ember-decorators#145

@buschtoens
Copy link
Owner Author

The more I think about this, the less I like being able to do #7 in the first place.

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

1 participant