0.5.0 • Published 7 years ago

aurelia-property-injection v0.5.0

Weekly downloads
72
License
CC0-1.0
Repository
github
Last release
7 years ago

aurelia-property-injection

npm version CircleCI

This plugin enables the core Aurelia's DI Container to inject dependencies into class instance properties, lifting the constructor from being the dependency bearer and decoupling child classes from parent dependencies.

The implementation follows the Convention over configuration paradigm, assuming the presence of a static injectProperties enumeration of property: Type to satisfy dependencies. For example, having a class like this:

import {Router} from 'aurelia-router';

export class MyClass {

  static injectProperties = {
    router: Router
  };

}

the container will produce an instance of MyClass with the current Router available in the router property.

It also provides extended implementations of the core inject and autoinject decorators, e.g.

import {inject} from 'aurelia-property-injection';
import {Router} from 'aurelia-router';

export class MyClass {

  @inject(Router)
  router;

}

and for TypeScript

import {autoinject} from 'aurelia-property-injection';

export class MyClass {

  @autoinject
  private router: Router;

}

Installing the plugin

Install the plugin via NPM:

npm install --save aurelia-property-injection

Enabling the plugin

To enable the plugin, simply use it in the Aurelia's main configuration of your application:

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .developmentLogging()
    .plugin('aurelia-property-injection');

  aurelia.start().then(() => aurelia.setRoot());
}
0.5.0

7 years ago

0.4.4

7 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.1.0

9 years ago