impl update lock for block workspace
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user