1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

Revert "Ps/avoid state emit until updated (#7124)" (#7187)

This reverts commit 38c335d8fb.
This commit is contained in:
Matt Gibson
2023-12-12 08:07:42 -05:00
committed by GitHub
parent 79dbe051c8
commit 08b69fffe1
10 changed files with 205 additions and 1126 deletions

View File

@@ -19,11 +19,6 @@ type KeyDefinitionOptions<T> = {
* @returns The fully typed version of your state.
*/
readonly deserializer: (jsonValue: Jsonify<T>) => T;
/**
* The number of milliseconds to wait before cleaning up the state after the last subscriber has unsubscribed.
* Defaults to 1000ms.
*/
readonly cleanupDelayMs?: number;
};
/**
@@ -47,12 +42,8 @@ export class KeyDefinition<T> {
private readonly options: KeyDefinitionOptions<T>,
) {
if (options.deserializer == null) {
throw new Error(`'deserializer' is a required property on key ${this.errorKeyName}`);
}
if (options.cleanupDelayMs <= 0) {
throw new Error(
`'cleanupDelayMs' must be greater than 0. Value of ${options.cleanupDelayMs} passed to key ${this.errorKeyName} `,
`'deserializer' is a required property on key ${stateDefinition.name} > ${key}`,
);
}
}
@@ -64,13 +55,6 @@ export class KeyDefinition<T> {
return this.options.deserializer;
}
/**
* Gets the number of milliseconds to wait before cleaning up the state after the last subscriber has unsubscribed.
*/
get cleanupDelayMs() {
return this.options.cleanupDelayMs < 0 ? 0 : this.options.cleanupDelayMs ?? 1000;
}
/**
* Creates a {@link KeyDefinition} for state that is an array.
* @param stateDefinition The state definition to be added to the KeyDefinition
@@ -153,10 +137,6 @@ export class KeyDefinition<T> {
? `${scope}_${userId}_${this.stateDefinition.name}_${this.key}`
: `${scope}_${this.stateDefinition.name}_${this.key}`;
}
private get errorKeyName() {
return `${this.stateDefinition.name} > ${this.key}`;
}
}
export type StorageKey = Opaque<string, "StorageKey">;