UNPKG

1.45 kBTypeScriptView Raw
1/**
2@license
3Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
4This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7Code distributed by Google as part of the polymer project is also
8subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9*/
10import { ReducersMapObject, StoreEnhancer } from 'redux';
11export interface LazyStore {
12 addReducers: (newReducers: ReducersMapObject) => void;
13}
14/**
15 A Redux store enhancer that lets you lazy-install reducers after the store
16 has booted up. Use this if your application lazy-loads routes that are connected
17 to a Redux store.
18
19 Example:
20
21 import { combineReducers } from 'redux';
22 import { lazyReducerEnhancer } from 'pwa-helpers/lazy-reducer-enhancer.js';
23 import someReducer from './reducers/someReducer.js';
24
25 export const store = createStore(
26 (state, action) => state,
27 compose(lazyReducerEnhancer(combineReducers))
28 );
29
30 Then, in your page/element, you can lazy load a specific reducer with:
31
32 store.addReducers({
33 someReducer
34 });
35*/
36export declare const lazyReducerEnhancer: (combineReducers: typeof import("redux").combineReducers) => StoreEnhancer<LazyStore, {}>;