import { Action, BasicAdapterMethods, ReactionsWithSelectors, Selectors, SyntheticSources, WithGetState, WithNoopReaction, WithUpdateReaction } from '@state-adapt/core'; import { Observable } from 'rxjs'; import { Sources } from '../stores/sources.type'; import { SmartStore } from '../stores/smart-store.interface'; export interface GlobalStoreMethods { readonly value: any; select: (sel: any) => Observable; dispatch: (action: any) => any; } /** A store's initial state, either as a plain value or as a factory function that returns it. A factory runs once per activation: the store calls it when it activates, holds onto that value for as long as it stays active, and discards it when it deactivates. So a store that is reset always goes back to what its *current* activation started from. Reading state from an inactive store calls the factory for that read alone. ```typescript const name = adapt(() => localStorage.getItem('name') ?? 'John'); ``` @hidden */ export type InitialState = State | (() => State); export type DefaultReactions = BasicAdapterMethods & (State extends object ? WithUpdateReaction : unknown) & WithNoopReaction; type SourceObject, R extends ReactionsWithSelectors> = Sources> & Sources; type ObservableSource = Observable | Observable[] | Observable> | Observable>[]; export type ConcreteSourceArg, R extends ReactionsWithSelectors> = SourceObject | ObservableSource; type StrictSources = { [K in keyof ReturnedSources]?: K extends keyof Allowed ? Allowed[K] : never; }; export type SourceArg, R extends ReactionsWithSelectors, ReturnedSources = unknown> = ConcreteSourceArg | ((detachedStore: SmartStore>) => StrictSources> | ObservableSource); export type InitializedReactions = {}, R extends ReactionsWithSelectors = {}> = ({} extends R ? {} : R) & DefaultReactions; export type InitializedSmartStore = {}, R extends ReactionsWithSelectors = {}> = SmartStore> & SyntheticSources>; export interface AdaptOptions = {}, R extends ReactionsWithSelectors = {}, ReturnedSources = unknown> { path?: string; adapter?: R & { selectors?: S; }; sources?: SourceArg; } export declare function isAdaptOptions = {}, R extends ReactionsWithSelectors = {}>(options: AdaptOptions | undefined | R): options is AdaptOptions; export type NotAdaptOptions = { path?: never; adapter?: never; sources?: never; }; export {};