Created
February 19, 2015 22:47
-
-
Save maciejsmolinski/e69c7635461b21941794 to your computer and use it in GitHub Desktop.
ES6 Repo + DI
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
class CoreRepository { | |
static inject () { | |
return []; | |
} | |
static instance () { | |
var deps = this.inject(); | |
return new this(...deps); | |
} | |
} | |
class Repository extends CoreRepository { | |
constructor (http) { | |
this.http = http; | |
} | |
static inject () { | |
return [ | |
{ get: function () {} } | |
]; | |
} | |
} | |
console.log(Repository.instance()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment