mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
Combined State (#7383)
* Introduce Combined State * Cleanup Test * Update Fakes * Address PR Feedback * Update libs/common/src/platform/state/implementations/default-active-user-state.ts Co-authored-by: Matt Gibson <mgibson@bitwarden.com> * Prettier * Get rid of ReplaySubject reference --------- Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
This commit is contained in:
@@ -4,12 +4,22 @@ import { UserId } from "../../types/guid";
|
||||
|
||||
import { StateUpdateOptions } from "./state-update-options";
|
||||
|
||||
export type CombinedState<T> = readonly [userId: UserId, state: T];
|
||||
|
||||
/**
|
||||
* A helper object for interacting with state that is scoped to a specific user.
|
||||
*/
|
||||
export interface UserState<T> {
|
||||
/**
|
||||
* Emits a stream of data.
|
||||
*/
|
||||
readonly state$: Observable<T>;
|
||||
readonly getFromState: () => Promise<T>;
|
||||
|
||||
/**
|
||||
* Emits a stream of data alongside the user id the data corresponds to.
|
||||
*/
|
||||
readonly combinedState$: Observable<CombinedState<T>>;
|
||||
|
||||
/**
|
||||
* Updates backing stores for the active user.
|
||||
* @param configureState function that takes the current state and returns the new state
|
||||
|
||||
Reference in New Issue
Block a user