Created
November 12, 2014 14:46
-
-
Save OliverJAsh/f77efca56cdf1bb1676d to your computer and use it in GitHub Desktop.
DI: Car -> Engine
This file contains hidden or 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
/* jshint esnext: true */ | |
import * as di from 'di/src'; | |
class Car { | |
constructor(engine) { | |
console.log('Car constructor engine: %s', engine); | |
} | |
} | |
// TODO: Fix ES6 class annotations | |
// As per: https://github.com/angular/di.js/issues/80 | |
di.annotate(Car, new di.Inject('Engine')); | |
var injector = new di.Injector(); | |
di.annotate(run, new di.InjectLazy(Car)); | |
function run(createCar) { | |
createCar('Engine', 'some-engine') | |
} | |
injector.get(run); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment