How to use the aurelia-metadata.Decorators.configure function in aurelia-metadata

To help you get started, we’ve selected a few aurelia-metadata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cmichaelgraham / aurelia-ts-port / aurelia-latest / templating / decorators.js View on Github external
return function(target){
    Metadata.on(target).add(new UseViewStrategy(path));
  }
}

Decorators.configure.parameterizedDecorator('useView', useView);

export function noView(target){
  var deco = function(target){
    Metadata.on(target).add(new NoViewStrategy());
  };

  return target ? deco(target) : deco;
}

Decorators.configure.simpleDecorator('noView', noView);

export function elementConfig(target){
  var deco = function(target){
    Metadata.on(target).add(new ElementConfigResource());
  };

  return target ? deco(target) : deco;
}

Decorators.configure.simpleDecorator('elementConfig', elementConfig);
github aurelia / templating / dist / es6 / decorators.js View on Github external
throw new Error(`'${name}' is not a valid ${type} name.  Upper-case letters are not allowed because the DOM is not case-sensitive.`)
  }
}

export function behavior(override){
  return function(target){
    if(override instanceof HtmlBehaviorResource){
      Reflect.defineMetadata(Metadata.resource, override, target);
    }else{
      var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
      Object.assign(resource, override);
    }
  }
}

Decorators.configure.parameterizedDecorator('behavior', behavior);

export function customElement(name){
  validateBehaviorName(name, 'custom element');
  return function(target){
    var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
    resource.elementName = name;
  }
}

Decorators.configure.parameterizedDecorator('customElement', customElement);

export function customAttribute(name, defaultBindingMode){
  validateBehaviorName(name, 'custom attribute');
  return function(target){
    var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
    resource.attributeName = name;
github cmichaelgraham / aurelia-ts-port / aurelia-ts / templating / decorators.ts View on Github external
import {ElementConfigResource} from './element-config';
import {ViewStrategy, UseViewStrategy, NoViewStrategy} from './view-strategy';
import {HtmlBehaviorResource} from './html-behavior';

export function behavior(override):any{
  return function(target){
    if(override instanceof HtmlBehaviorResource){
      Reflect.defineMetadata(Metadata.resource, override, target);
    }else{
      var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
      Object.assign(resource, override);
    }
  }
}

Decorators.configure.parameterizedDecorator('behavior', behavior);

export function customElement(name):any{
  return function(target){
    var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
    resource.elementName = name;
  }
}

Decorators.configure.parameterizedDecorator('customElement', customElement);

export function customAttribute(name):any{
  return function(target){
    var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
    resource.attributeName = name;
  }
}
github aurelia / dependency-injection / dist / aurelia-dependency-injection.js View on Github external
export function singleton(keyOrRegisterInChild? : any, registerInChild? : boolean = false){
  return registration(new SingletonRegistration(keyOrRegisterInChild, registerInChild));
}

export function instanceActivator(value : any){
  return function(target){
    Metadata.define(Metadata.instanceActivator, value, target);
  }
}

export function factory(){
  return instanceActivator(FactoryActivator.instance);
}

Decorators.configure.simpleDecorator('autoinject', autoinject);
Decorators.configure.parameterizedDecorator('inject', inject);
Decorators.configure.parameterizedDecorator('registration', registration);
Decorators.configure.parameterizedDecorator('transient', transient);
Decorators.configure.parameterizedDecorator('singleton', singleton);
Decorators.configure.parameterizedDecorator('instanceActivator', instanceActivator);
Decorators.configure.parameterizedDecorator('factory', factory);
github aurelia / dependency-injection / dist / es6 / aurelia-dependency-injection.js View on Github external
export function instanceActivator(value: any) {
  return function(target) {
    Metadata.define(Metadata.instanceActivator, value, target);
  };
}

export function factory() {
  return instanceActivator(FactoryActivator.instance);
}

Decorators.configure.simpleDecorator('autoinject', autoinject);
Decorators.configure.parameterizedDecorator('inject', inject);
Decorators.configure.parameterizedDecorator('registration', registration);
Decorators.configure.parameterizedDecorator('transient', transient);
Decorators.configure.parameterizedDecorator('singleton', singleton);
Decorators.configure.parameterizedDecorator('instanceActivator', instanceActivator);
Decorators.configure.parameterizedDecorator('factory', factory);
github cmichaelgraham / aurelia-ts-port / aurelia-ts / templating / decorators.js View on Github external
import { ChildObserver } from './children';
import { ElementConfigResource } from './element-config';
import { ViewStrategy, UseViewStrategy, NoViewStrategy } from './view-strategy';
import { HtmlBehaviorResource } from './html-behavior';
export function behavior(override) {
    return function (target) {
        if (override instanceof HtmlBehaviorResource) {
            Reflect.defineMetadata(Metadata.resource, override, target);
        }
        else {
            var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
            Object.assign(resource, override);
        }
    };
}
Decorators.configure.parameterizedDecorator('behavior', behavior);
export function customElement(name) {
    return function (target) {
        var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
        resource.elementName = name;
    };
}
Decorators.configure.parameterizedDecorator('customElement', customElement);
export function customAttribute(name) {
    return function (target) {
        var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
        resource.attributeName = name;
    };
}
Decorators.configure.parameterizedDecorator('customAttribute', customAttribute);
export function templateController(target) {
    var deco = function (target) {
github cmichaelgraham / aurelia-ts-port / aurelia-ts / dependency-injection / index.js View on Github external
return registration(new SingletonRegistration(keyOrRegisterInChild, registerInChild));
}
export function instanceActivator(value) {
    return function (target) {
        Reflect.defineMetadata(Metadata.instanceActivator, value, target);
    };
}
export function factory() {
    return instanceActivator(FactoryActivator.instance);
}
Decorators.configure.simpleDecorator('autoinject', autoinject);
Decorators.configure.parameterizedDecorator('inject', inject);
Decorators.configure.parameterizedDecorator('registration', registration);
Decorators.configure.parameterizedDecorator('transient', transient);
Decorators.configure.parameterizedDecorator('singleton', singleton);
Decorators.configure.parameterizedDecorator('instanceActivator', instanceActivator);
Decorators.configure.parameterizedDecorator('factory', factory);
github cmichaelgraham / aurelia-ts-port / dist / es6 / templating / decorators.js View on Github external
import { ChildObserver } from './children';
import { ElementConfigResource } from './element-config';
import { ViewStrategy, UseViewStrategy, NoViewStrategy } from './view-strategy';
import { HtmlBehaviorResource } from './html-behavior';
export function behavior(override) {
    return function (target) {
        if (override instanceof HtmlBehaviorResource) {
            Reflect.defineMetadata(Metadata.resource, override, target);
        }
        else {
            var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
            Object.assign(resource, override);
        }
    };
}
Decorators.configure.parameterizedDecorator('behavior', behavior);
export function customElement(name) {
    return function (target) {
        var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
        resource.elementName = name;
    };
}
Decorators.configure.parameterizedDecorator('customElement', customElement);
export function customAttribute(name) {
    return function (target) {
        var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
        resource.attributeName = name;
    };
}
Decorators.configure.parameterizedDecorator('customAttribute', customAttribute);
export function templateController(target) {
    var deco = function (target) {
github cmichaelgraham / aurelia-ts-port / aurelia-ts / templating / decorators.ts View on Github external
resource.attributeName = name;
  }
}

Decorators.configure.parameterizedDecorator('customAttribute', customAttribute);

export function templateController(target?):any{
  var deco = function(target){
    var resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, target);
    resource.liftsContent = true;
  };

  return target ? deco(target) : deco;
}

Decorators.configure.simpleDecorator('templateController', templateController);

export function bindable(nameOrConfigOrTarget, key?, descriptor?):any{
  var deco = function(target, key, descriptor){
    var actualTarget = key ? target.constructor : target, //is it on a property or a class?
    resource = Metadata.getOrCreateOwn(Metadata.resource, HtmlBehaviorResource, actualTarget),
        prop;

    if(key){ //is it on a property or a class?
      nameOrConfigOrTarget = nameOrConfigOrTarget || {};
      nameOrConfigOrTarget.name = key;
    }

    prop = new BindableProperty(nameOrConfigOrTarget);
    return prop.registerWith(actualTarget, resource, descriptor);
  };
github cmichaelgraham / aurelia-ts-port / aurelia-ts / dependency-injection / index.ts View on Github external
Metadata.on(target).add(new TransientRegistration(key));
  }
}

export function singleton(keyOrRegisterInChild, registerInChild=false){
  return function(target){
    Metadata.on(target).add(new SingletonRegistration(keyOrRegisterInChild, registerInChild));
  }
}

export function factory(target) {
  Metadata.on(target).add(new FactoryActivator());
}

Decorators.configure.parameterizedDecorator('inject', inject);
Decorators.configure.parameterizedDecorator('transient', transient);
Decorators.configure.parameterizedDecorator('singleton', singleton);
Decorators.configure.parameterizedDecorator('factory', factory);