Created
March 4, 2019 10:37
-
-
Save rix0rrr/c62ac7c5bbc2f6f16b695865bb76c30e to your computer and use it in GitHub Desktop.
apps apps apps
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
// Simple case, my "app" is just a stack | |
const app = new cdk.App(); | |
new MyStack(app, 'MyFrobulizerConsumer'); | |
//--------------------------------------------------------------------------- | |
// More complex case, my "app" is a subclass of App because it contains multiple | |
// stacks and I can organize them | |
new MyApp('TweetFrobulizer'); | |
//--------------------------------------------------------------------------- | |
// Instantiating multiple apps or the same app multiple times | |
new MyApp('TweetFrobulizerEU', { ... }); | |
new MyApp('TweetFrobulizerUS', { ... }); | |
new OpTools('TweetFrobulizerTools'); |
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
// Simple case, my "app" is just a stack | |
// ==> This is the same | |
const app = new cdk.App(); | |
new MyStack(app, 'MyFrobulizerConsumer'); | |
//--------------------------------------------------------------------------- | |
// More complex case | |
// I still need to instantiate a boilerplate thing that has nothing to | |
// do with *MY* code | |
const app = new cdk.App(); | |
new MyApp(app, 'TweetFrobulizer'); | |
//--------------------------------------------------------------------------- | |
// Instantiating multiple apps or the same app multiple times | |
// Again, this boilerplate thing is here | |
const app = new cdk.App(); | |
new MyApp(app, 'TweetFrobulizerEU', { ... }); | |
new MyApp(app, 'TweetFrobulizerUS', { ... }); | |
new OpTools(app, 'TweetFrobulizerTools'); | |
// So the difference as I see it is in the simple case, we can retcon that | |
// the App you instantiate is actually *your* app, and we can hide the | |
// machinery of coming up with a proper (shared) Root instance inside that class. | |
// | |
// Whereas in the other scenario, you HAVE to instantiate that Root object, | |
// but it's obviously framework machinery sticking out. | |
// | |
// Now the downsides of making users subclass App is that: | |
// 1) The signature will be slightly different from construct, which will be | |
// confusing. | |
// 2) Their stuff isn't as obviously reusble as when it was a cdk.Construct. | |
// | |
// Mitigations for making the `App` class stick out like that: | |
// 1) Rename it? But to what? | |
// 2) Static singleton accessor? But named what? Probably shouldn't involve | |
// the word "root" anywhere or we're going to get back into tree building | |
// discussions that we don't want to have. | |
const host = new cdk.Host(); | |
// or | |
const model = new cdk.AppModel(); | |
// or | |
new MyStack(cdk.Host.root, 'MyStack'); | |
new MyStack(cdk.App.appScope, 'MyStack'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment