Skip to content

Instantly share code, notes, and snippets.

@acomagu
Created January 10, 2021 02:02
Show Gist options
  • Save acomagu/7a5252b3650f0f1fbf2131d0d67bfc81 to your computer and use it in GitHub Desktop.
Save acomagu/7a5252b3650f0f1fbf2131d0d67bfc81 to your computer and use it in GitHub Desktop.
const { Node, Construct } = require('constructs');
class RootConstruct extends Construct {
onSynthesize() {
console.log(this.synthesize());
}
synthesize() {
return Object.assign({},
...Node.of(this).children.map(child => child.synthesize()),
);
}
}
const root = new RootConstruct(undefined, 'root');
class AConstruct extends Construct {
synthesize() {
return { 'りんご': 'ごりら' };
}
}
new AConstruct(root, 'a');
class BConstruct extends Construct {
synthesize() {
return { 'らっぱ': 'ぱせり' };
}
}
new BConstruct(root, 'b');
Node.of(root).synthesize({});
const { Node, Construct } = require('constructs');
class HighLevelConstruct extends Construct {
synthesize() {
return Object.assign({},
...Node.of(this).children.map(child => child.synthesize()),
);
}
}
class RootConstruct extends HighLevelConstruct {
onSynthesize() {
console.log(this.synthesize());
}
}
const root = new RootConstruct(undefined, 'root');
class AConstruct extends Construct {
synthesize() {
return { 'りんご': 'ごりら' };
}
}
class BConstruct extends Construct {
synthesize() {
return { 'らっぱ': 'ぱせり' };
}
}
class ABConstruct extends HighLevelConstruct {
constructor(host, id) {
super(host, id);
new AConstruct(this, 'a');
new BConstruct(this, 'b');
}
}
new ABConstruct(root, 'ab');
Node.of(root).synthesize({});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment