Last active
August 29, 2015 14:09
-
-
Save msfrisbie/23ed5df17ce8eaf506a7 to your computer and use it in GitHub Desktop.
Dependency Injection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AtScript | |
import {Component} from 'angular'; | |
import {Server} from './server'; | |
@Component({selector: 'foo'}) | |
export class MyComponent { | |
constructor(server:Server) { | |
this.server = server; | |
} | |
} | |
// ES6 | |
import * as rtts from 'rtts'; | |
import {Component} from 'angular'; | |
import {Server} from './server'; | |
export class MyComponent { | |
constructor(server) { | |
rtts.types(server, Server); | |
this.server = server; | |
} | |
} | |
// new Dependency Injection!!! | |
MyComponent.parameters = [{is:Server}]; | |
MyComponent.annotate = [ | |
new Component({selector: 'foo'}) | |
]; | |
// Annotations | |
// transpiled ES5 | |
MyComponent.annotate = [new Inject(Server)]; | |
// Control of instance reuse | |
// Singleton (same class for each injecion) | |
export class FooClass {} | |
// Create new class for each injection | |
@TransientScope | |
export class FooClass {} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment