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