mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
27 lines
725 B
TypeScript
27 lines
725 B
TypeScript
import { Observable } from "rxjs";
|
|
|
|
export const DEFAULT_OPTIONS = {
|
|
shouldUpdate: () => true,
|
|
combineLatestWith: null as Observable<unknown>,
|
|
msTimeout: 1000,
|
|
};
|
|
|
|
type DefinitelyTypedDefault<T, TCombine> = Omit<
|
|
typeof DEFAULT_OPTIONS,
|
|
"shouldUpdate" | "combineLatestWith"
|
|
> & {
|
|
shouldUpdate: (state: T, dependency: TCombine) => boolean;
|
|
combineLatestWith?: Observable<TCombine>;
|
|
};
|
|
|
|
export type StateUpdateOptions<T, TCombine> = Partial<DefinitelyTypedDefault<T, TCombine>>;
|
|
|
|
export function populateOptionsWithDefault<T, TCombine>(
|
|
options: StateUpdateOptions<T, TCombine>,
|
|
): StateUpdateOptions<T, TCombine> {
|
|
return {
|
|
...(DEFAULT_OPTIONS as StateUpdateOptions<T, TCombine>),
|
|
...options,
|
|
};
|
|
}
|