This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/app/lib/dirty-keys.js
Roman Rizzi 7a2e8d3ead
DEV: Add the missing app subdirectory (#9499)
* DEV: Add missing  directory to the Discourse ember app

* DEV: Resolve imports correctly
2020-04-23 10:07:54 -03:00

33 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];
}
}
}