2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-07 12:02:53 +08:00
discourse/app/assets/javascripts/discourse/lib/dirty-keys.js.es6

32 lines
510 B
JavaScript

export default class DirtyKeys {
constructor(name) {
this.name = name;
this._keys = {};
}
keyDirty(key, options) {
options = options || {};
options.dirty = true;
this._keys[key] = options;
}
forceAll() {
this.keyDirty('*');
}
allDirty() {
return !!this._keys['*'];
}
optionsFor(key) {
return this._keys[key] || { dirty: false };
}
renderedKey(key) {
if (key === '*') {
this._keys = {};
} else {
delete this._keys[key];
}
}
}