Request-scoped state bag that flows across hook runs and engine instances.
Use symbols for private plugin state and strings for shared cross-plugin contracts.
// Private plugin state (symbol key) const CACHE_STATE = Symbol('cache'); ctx.scope.set(CACHE_STATE, { key, rule }); // Shared cross-plugin contract (string key) ctx.scope.set('serializedKey', key); Copy
// Private plugin state (symbol key) const CACHE_STATE = Symbol('cache'); ctx.scope.set(CACHE_STATE, { key, rule }); // Shared cross-plugin contract (string key) ctx.scope.set('serializedKey', key);
Delete a key from the scope.
Get a value from the scope.
const state = ctx.scope.get<CacheState>(CACHE_STATE); Copy
const state = ctx.scope.get<CacheState>(CACHE_STATE);
Check if a key exists in the scope.
Set a value in the scope.
ctx.scope.set(CACHE_STATE, { key: 'abc', rule }); Copy
ctx.scope.set(CACHE_STATE, { key: 'abc', rule });
Request-scoped state bag that flows across hook runs and engine instances.
Use symbols for private plugin state and strings for shared cross-plugin contracts.
Example