impl update lock for block workspace

This commit is contained in:
Niels Lyngsø
2024-05-21 23:32:50 +02:00
parent 35113f797c
commit 6dd87da0d8

View File

@@ -65,9 +65,30 @@ export class UmbBlockElementManager extends UmbControllerBase {
}
async setPropertyValue(alias: string, value: unknown) {
this.initiatePropertyValueChange();
await this.#getDataPromise;
this.#data.update({ [alias]: value });
this.finishPropertyValueChange();
}
#updateLock = 0;
initiatePropertyValueChange() {
this.#updateLock++;
this.#data.mute();
// TODO: When ready enable this code will enable handling a finish automatically by this implementation 'using myState.initiatePropertyValueChange()' (Relies on TS support of Using) [NL]
/*return {
[Symbol.dispose]: this.finishPropertyValueChange,
};*/
}
finishPropertyValueChange = () => {
this.#updateLock--;
this.#triggerPropertyValueChanges();
};
#triggerPropertyValueChanges() {
if (this.#updateLock === 0) {
this.#data.unmute();
}
}
public createPropertyDatasetContext(host: UmbControllerHost) {