Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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