UNPKG

2.2 kBTypeScriptView Raw
1import { AnyAction, Dispatch, Middleware, Reducer, Store, StoreEnhancer, Unsubscribe } from 'redux';
2import { Observable } from 'rxjs';
3import { ObservableStore } from './observable-store';
4import { Comparator, PathSelector, Selector } from './selectors';
5/**
6 * This is the public interface of @angular-redux/store. It wraps the global
7 * redux store and adds a few other add on methods. It's what you'll inject
8 * into your Angular application as a service.
9 */
10export declare abstract class NgRedux<RootState> implements ObservableStore<RootState> {
11 /** @hidden, @deprecated */
12 static instance?: ObservableStore<any>;
13 /**
14 * Configures a Redux store and allows NgRedux to observe and dispatch
15 * to it.
16 *
17 * This should only be called once for the lifetime of your app, for
18 * example in the constructor of your root component.
19 *
20 * @param rootReducer Your app's root reducer
21 * @param initState Your app's initial state
22 * @param middleware Optional Redux middlewares
23 * @param enhancers Optional Redux store enhancers
24 */
25 abstract configureStore: (rootReducer: Reducer<RootState, AnyAction>, initState: RootState, middleware?: Middleware[], enhancers?: StoreEnhancer<RootState>[]) => void;
26 /**
27 * Accepts a Redux store, then sets it in NgRedux and
28 * allows NgRedux to observe and dispatch to it.
29 *
30 * This should only be called once for the lifetime of your app, for
31 * example in the constructor of your root component. If configureStore
32 * has been used this cannot be used.
33 *
34 * @param store Your app's store
35 */
36 abstract provideStore: (store: Store<RootState>) => void;
37 abstract dispatch: Dispatch<AnyAction>;
38 abstract getState: () => RootState;
39 abstract subscribe: (listener: () => void) => Unsubscribe;
40 abstract replaceReducer: (nextReducer: Reducer<RootState, AnyAction>) => void;
41 abstract select: <SelectedType>(selector?: Selector<RootState, SelectedType>, comparator?: Comparator) => Observable<SelectedType>;
42 abstract configureSubStore: <SubState>(basePath: PathSelector, localReducer: Reducer<SubState, AnyAction>) => ObservableStore<SubState>;
43}