()
| 240 | } |
| 241 | |
| 242 | private loadStateInternal() { |
| 243 | this.storage.get(this.localStorageKey, (data: any) => { |
| 244 | switch (this.meta) { |
| 245 | case StateManagerImplState.INITIAL: |
| 246 | case StateManagerImplState.READY: |
| 247 | case StateManagerImplState.SAVING: |
| 248 | case StateManagerImplState.SAVING_OVERRIDE: |
| 249 | this.logWarn('Unexpected state. Possible data race!'); |
| 250 | return; |
| 251 | case StateManagerImplState.LOADING: |
| 252 | this.meta = StateManagerImplState.READY; |
| 253 | this.applyState(data[this.localStorageKey]); |
| 254 | this.releaseBarrier(); |
| 255 | return; |
| 256 | case StateManagerImplState.ONCHANGE_RACE: |
| 257 | this.meta = StateManagerImplState.RECOVERY; |
| 258 | this.loadStateInternal(); |
| 259 | // eslint-disable-next-line no-fallthrough |
| 260 | case StateManagerImplState.RECOVERY: |
| 261 | this.meta = StateManagerImplState.READY; |
| 262 | this.applyState(data[this.localStorageKey]); |
| 263 | this.releaseBarrier(); |
| 264 | this.notifyListeners(); |
| 265 | } |
| 266 | }); |
| 267 | } |
| 268 | |
| 269 | async loadState(): Promise<void> { |
| 270 | switch (this.meta) { |
no test coverage detected