UNPKG

marionette-decorators

Version:
1 lines 1.84 kB
export function appRoute(e){return function t(r,o,n){r.appRoutes=r.appRoutes||{};if(_.isFunction(r.appRoutes)){throw new Error("The on decorator is not compatible with an appRoutes method")}if(!e){throw new Error("The on decorator requires an appRoute argument")}r.appRoutes[e]=o;return n}};export function attribute(e,t){return function r(o){o.prototype[e]=t}};export function attributes(e){return function t(r){for(var o in e){r.prototype[o]=e[o]}}};export function className(e){return function t(r){r.className=e}};export function controller(e){return function t(r){r.prototype.controller=e}};export function on(e){return function(t,r,o){t.events=t.events||{};if(_.isFunction(t.events)){throw new Error("The on decorator is not compatible with an events method")}if(!e){throw new Error("The on decorator requires an eventName argument")}t.events[e]=r;return o}};export function region(e){return function(t,r,o){t.regions=t.regions||{};if(_.isFunction(t.regions)){throw new Error("The region decorator is not compatible with a regions method")}if(!e){throw new Error("The on decorator requires an regionName argument")}if(t[r]==null){throw new Error("You either haven't set the region value, or set it to a value that is not visible before the constructor has run (Try using a getter!)")}t.regions[e]=t[r];return o}};export function radioRequest(e){return function(t,r,o){t.radioRequests=t.radioRequests||{};if(_.isFunction(t.radioRequests)){throw new Error("The radioRequest decorator is not compatible with an events method")}if(!e){throw new Error("The radioRequest decorator requires a request argument (String value)")}t.radioRequests[e]=r;return o}};export function tagName(e){return function t(r){r.prototype.tagName=e}};export function template(e,t){if(undefined===t){t={}}return function r(o){o.prototype.template=_.template(e,t)}};