UNPKG

1.65 kBTypeScriptView Raw
1import { AnyAction, Reducer, Store } from 'redux';
2import { Observable } from 'rxjs';
3import { Comparator, PathSelector, Selector } from './selectors';
4/**
5 * This interface represents the glue that connects the
6 * subscription-oriented Redux Store with the RXJS Observable-oriented
7 * Angular component world.
8 *
9 * Augments the basic Redux store interface with methods to
10 * enable selection and fractalization.
11 */
12export interface ObservableStore<StateType> extends Store<StateType> {
13 /**
14 * Select a slice of state to expose as an observable.
15 *
16 * @typeparam S
17 * @param selector key or function to select a part of the state
18 * @param [comparator] Optional
19 * comparison function called to test if an item is distinct
20 * from the previous item in the source.
21 *
22 * @returns An Observable that emits items from the
23 * source Observable with distinct values.
24 */
25 select: <SelectedType>(selector: Selector<StateType, SelectedType>, comparator?: Comparator) => Observable<SelectedType>;
26 /**
27 * Carves off a 'subStore' or 'fractal' store from this one.
28 *
29 * The returned object is itself an observable store, however any
30 * selections, dispatches, or invocations of localReducer will be
31 * specific to that substore and will not know about the parent
32 * ObservableStore from which it was created.
33 *
34 * This is handy for encapsulating component or module state while
35 * still benefiting from time-travel, etc.
36 */
37 configureSubStore: <SubState>(basePath: PathSelector, localReducer: Reducer<SubState, AnyAction>) => ObservableStore<SubState>;
38}