import { Observable } from 'rxjs'; import { BordaClient, BordaParams, Document, IndexedDB } from '@borda/client'; import { Action, Store } from '@reduxjs/toolkit'; import type { FastOptions } from './fast'; export type BordaStateFastParams = Pick; export interface SetStateOptions { /** * whether or not to useCache the state in local storage * default: true */ useCache?: boolean; } export interface UnsetStateParams { /** * whether or not to also clean local storage * default: true */ clearCache?: boolean; } export interface ResetStateParams { /** * whether or not to also clean local storage * default: true */ clearCache?: boolean; } export interface ListenerOptions { context: boolean; copy: boolean; } export interface StateContext { path: string; prev: T; next: T; } export type StateDocument = Document | Document[] | string | number | null | undefined | any; export interface BordaStateParams extends BordaParams { inspect?: boolean; traceLimit?: number; reducers?: any; preloadedState?: any; cacheStore?: string; cacheVersion?: number; fast?: BordaStateFastParams; } export declare class Borda extends BordaClient { #private; static App: Record(path?: string, options?: { useCache: boolean; }) => T | Promise; setState: (key: string, value: T, options?: SetStateOptions & { useCache: boolean; }) => void | Promise; }>; get cache(): IndexedDB; constructor(params?: Partial); /** * mandatory method to initialize borda in the browser * which requires a cache and a store. * Note that this is a promise that must be awaited. */ browser(): Promise; /** * Action dispatcher * * @export * @template T * @param {(Action | ((dispatch: any) => Promise | void))} action * @returns {*} {Action} */ dispatch(action: Action | ((dispatch: any) => Promise | void)): Action; /** * Provides reactive data access to both borda and custom reducers. * The path is a string with dot notation in case of custom reducers. * To use a borda state, make sure you don't have any custom reducer with the same name. * * The context option provides the previous and next value of the state. * This is useful if you want to know what changed in the state. * * The copy option makes a copy of the state. Default to false. * * The borda option allows to access the internal borda state. * * @export * @template T * @param {string} path * @param {Partial} [options={ * context: false, * copy: false, * borda: false, * }] * @returns {*} {Observable} */ connect(path: string, options?: Partial void; borda: boolean; }>): Observable; /** * Synchronously grab a piece of data from state controlled by custom reducers. * The path is a string with dot notation. If path isn't specified, the whole state is returned. * * @export * @template T * @param {string} [path] * @returns {*} {T} */ getState(path?: string, options?: { useCache: boolean; }): T; getState(path: string, options: { useCache: boolean; }): Promise; setState(key: string, value: T, options: SetStateOptions & { useCache: boolean; }): Promise; setState(key: string, value: T, options?: SetStateOptions & { useCache: boolean; }): void; unsetState(key: string, options: UnsetStateParams & { clearCache: boolean; }): Promise; unsetState(key: string, options?: UnsetStateParams & { clearCache: boolean; }): void; /** * Reset borda state and optionally clear the cache. * To reset custom reducers, you must implement your own reset action and `dispatch(myResetAction())` */ resetState(options: ResetStateParams): Promise; resetState(options?: ResetStateParams): void; } export declare const BordaBrowser: typeof Borda;