// @flow import type React from 'React' import type { Observable } from 'rxjs' export type Undux = $ObjMap> type Lift = (value: V) => Lifted type Lifted = { key: $Keys, previousValue: T, value: T, } export type Exactly = T export type Options = { isDevMode: boolean, } export interface Store { get>(key: K): $ElementType; set, V: $ElementType>(key: K): (value: V) => void; setFrom_EXPERIMENTAL((Store) => void): void; on>(key: K): Observable<$ElementType>; onAll(): Observable<$Values>>; getState(): $ReadOnly; } declare export class StoreSnapshot implements Store { get>(key: K): $ElementType; set, V: $ElementType>(key: K): (value: V) => void; setFrom_EXPERIMENTAL((Store) => void): void; on>(key: K): Observable<$ElementType>; onAll(): Observable<$Values>>; getState(): $ReadOnly; } declare export class StoreDefinition implements Store { get>(key: K): $ElementType; set, V: $ElementType>(key: K): (value: V) => void; setFrom_EXPERIMENTAL((Store) => void): void; on>(key: K): Observable<$ElementType>; onAll(): Observable<$Values>>; getCurrentSnapshot(): StoreSnapshot; getState(): $ReadOnly; } declare export function createStore( initialState: State, options?: Options, ): StoreDefinition> export type Effects = ( store: StoreDefinition, ) => StoreDefinition /** * @deprecated Use `Effects` instead. */ export type Plugin = ( store: StoreDefinition, ) => StoreDefinition export type ToStore = (s: State) => Store type ToStoreDefinition = (s: State) => StoreDefinition export type EffectsAs< States: { [alias: string]: any, }, > = ( stores: $ObjMap, ) => $ObjMap declare export function withLogger( store: StoreDefinition, ): StoreDefinition declare export function withReduxDevtools( store: StoreDefinition, ): StoreDefinition declare export function connect( store: StoreDefinition, ): , Props: { store: S, ... }>( Component: React.ComponentType, ) => Class>> // connectAs declare export function connectAs, ... }>( stores: Stores, ): ( Component: React.ComponentType, ) => Class>> // createConnectedStore export type ContainerProps = {| children: React.Node, effects?: Effects, initialState?: State, |} export type WithStore> = React.ComponentType<$Diff, { store: any }>> export type Connect = {| Container: React.ComponentType>, useStore: () => Store, withStore: , Props: { store: S, ... }>( Component: React.ComponentType, ) => Class>>, |} declare export function createConnectedStore( initialState: State, effects?: Effects, ): Connect // createConnectedStoreAs export type ContainerPropsAs< States: { [alias: string]: any, }, > = {| children: React.Node, effects?: EffectsAs, initialStates?: States, |} export type ToAny = (s: State) => any export type WithStores< ComponentType: React.ComponentType, States: { [alias: string]: any, }, > = React.ComponentType< $Diff, $ObjMap>, > export type ConnectAs< States: { [alias: string]: any, }, > = {| Container: React.ComponentType>, useStores: () => $ObjMap, withStores: >( Component: ComponentType, ) => React.ComponentType< $Diff, $ObjMap>, >, |} declare export function createConnectedStoreAs< States: { [alias: string]: any, }, >( initialStates: States, effects?: EffectsAs, ): ConnectAs>