Skip to content

Provide a helper to create custom decorators #30

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

Merged
merged 2 commits into from
Nov 14, 2016
Merged

Provide a helper to create custom decorators #30

merged 2 commits into from
Nov 14, 2016

Conversation

ktsn
Copy link
Member

@ktsn ktsn commented Nov 12, 2016

This PR depends on #29, please see #29 before seeing this

This PR adds createDecorator helper to let us create custom decorators for class-style vue components. The helper expects a callback function as the 1st argument and the callback will receive a component options object. So, we can easily create Vue component-specific decorators.

Example:

import Component, { createDecorator } from 'vue-class-component'

export const NoCache = createDecorator((options, key) => {
  options.computed[key].cache = false
})

@Component
class MyComp extends Vue {
  // the computed property will not be cached
  @NoCache
  get random () {
    return Math.random()
  }
}

@yyx990803
Copy link
Member

This is now conflicting after merging #29

@ktsn
Copy link
Member Author

ktsn commented Nov 14, 2016

@yyx990803 I've resolved the conflict.

@yyx990803 yyx990803 merged commit 0a11308 into vuejs:master Nov 14, 2016
@ktsn ktsn deleted the create-decorator-helper branch November 14, 2016 02:41
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

Successfully merging this pull request may close these issues.

2 participants