Created
April 12, 2018 16:11
-
-
Save bradharms/0241b3badf30a972f361bc59aba381b7 to your computer and use it in GitHub Desktop.
Example entry point for container-less DI-based application in ES6.
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
/** | |
* Example entry point for container-less DI-based application in ES6. | |
*/ | |
// Master list of all modules used in this configuration in alphabetical order | |
import aaa_ from './aaa'; | |
import bbb_ from './bbb'; | |
import ccc_ from './ccc'; | |
import altCcc_ from './alternates/ccc'; | |
import ddd_ from './ddd'; | |
import eee_ from './eee'; | |
const aaa = aaa_({ | |
// Service 'aaa' doesn't have any deps, but we use the xyz_({}) pattern for consistency | |
}); | |
const bbb = bbb_({ | |
// Deps are passed in as named arguments because its easier than | |
aaa | |
}); | |
const ccc = ccc_({ | |
aaa, | |
bbb | |
}); | |
const ddd = ddd_({ | |
aaa, | |
ccc | |
}); | |
const altCcc = altCcc_({ | |
bbb | |
}); | |
const eee = eee_({ | |
// We want eee to use an alternative version of the ccc module that has the same interface but a different implementation. | |
// The normal ccc module could have been used as well, but for whatever reason we don't want it here. | |
ccc: altCcc, | |
ddd | |
}); | |
// The app entry point happens to be inside of the eee module | |
eee.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment