MCPcopy Create free account
hub / github.com/aws/constructs / setContext

Method setContext

src/construct.ts:224–233  ·  view source on GitHub ↗

* This can be used to set contextual values. * Context must be set before any children are added, since children may consult context info during construction. * If the key already exists, it will be overridden. * @param key The context key * @param value The context value

(key: string, value: any)

Source from the content-addressed store, hash-verified

222 * @param value The context value
223 */
224 public setContext(key: string, value: any) {
225 if (this.children.length > 0) {
226 const names = this.children.map(c => c.node.id);
227 throw new Error('Cannot set context after children have been added: ' + names.join(','));
228 }
229 if (!this._context) {
230 this._context = {};
231 }
232 this._context[key] = value;
233 }
234
235 /**
236 * Retrieves a value from tree context if present. Otherwise, would throw an error.

Callers 2

construct.test.tsFile · 0.80
createTreeFunction · 0.80

Calls

no outgoing calls

Tested by 1

createTreeFunction · 0.64