Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lukemelia/b2e5c3ad7cc7dcb7e65b5bea08e82e4b to your computer and use it in GitHub Desktop.
Save lukemelia/b2e5c3ad7cc7dcb7e65b5bea08e82e4b to your computer and use it in GitHub Desktop.
Example of defining your own decorator macro using https://pzuraq.github.io/macro-decorators
import { reads }, macro from 'macro-decorators';
/* Usage:
*
* import { hasEnabledFeature } from 'yapp-ember-kit/macro-decorators';
*
* @reads('yappService.model') yapp;
* @hasEnabledFeature('teleportation') canTeleport;
*/
export function hasEnabledFeature(featureName, yappProperty='yapp') {
return macro({
get() {
let yapp = this[yappProperty];
return yapp && yapp.hasEnabledFeature(featureName);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment