提交 d21cbabe 编写于 作者: E Eric Amodio 提交者: Eric Amodio

Adds default context caching for objects

Clears  all cached config context values for objects
上级 16ffcb50
......@@ -89,6 +89,8 @@ class NullContext extends Context {
}
}
const configContextObject = Object.freeze({});
class ConfigAwareContextValuesContainer extends Context {
private static readonly _keyPrefix = 'config.';
......@@ -112,10 +114,23 @@ class ConfigAwareContextValuesContainer extends Context {
} else {
const changedKeys: string[] = [];
for (const configKey of event.affectedKeys) {
const contextKey = `config.${configKey}`;
let contextKey = `config.${configKey}`;
if (this._values.has(contextKey)) {
const value = this._values.get(contextKey);
this._values.delete(contextKey);
changedKeys.push(contextKey);
if (value === configContextObject) {
contextKey += '.';
for (const key of this._values.keys()) {
if (key.startsWith(contextKey)) {
this._values.delete(key);
changedKeys.push(key);
}
}
}
}
}
emitter.fire(new ArrayContextKeyChangeEvent(changedKeys));
......@@ -149,6 +164,8 @@ class ConfigAwareContextValuesContainer extends Context {
default:
if (Array.isArray(configValue)) {
value = JSON.stringify(configValue);
} else {
value = configContextObject;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册