mm
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
export class StateRegistry<V> {
|
||||
constructor(excuteCallback: (registry: Map<string, V | null>) => boolean) {
|
||||
this._excuteCallback = excuteCallback;
|
||||
}
|
||||
|
||||
_excuteCallback: (registry: Map<string, V | null>) => boolean;
|
||||
|
||||
_registryMap = new Map<string, V | null>();
|
||||
|
||||
insertKey = (key: string) => {
|
||||
this._registryMap.set(key, null);
|
||||
};
|
||||
|
||||
updateValue = (key: string, value: V) => {
|
||||
this._registryMap.set(key, value);
|
||||
};
|
||||
|
||||
deleteEntry = (key: string) => {
|
||||
this._registryMap.delete(key);
|
||||
};
|
||||
|
||||
execute = () => {
|
||||
return this._excuteCallback(this._registryMap);
|
||||
};
|
||||
|
||||
checkAllReady = () => {
|
||||
for (const i of this._registryMap.values()) {
|
||||
i == null;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user