UNPKG

ducks

Version:

🦆🦆🦆 Ducks is a Reducer Bundles Manager that Implementing the Redux Ducks Modular Proposal with Great Convenience.

89 lines 3.49 kB
/** * Ducks - https://github.com/huan/ducks * * @copyright 2020 Huan LI (李卓桓) <https://github.com/huan> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import { StoreEnhancer, Middleware, Store, Reducer } from 'redux'; import type { Epic, EpicMiddleware } from 'redux-observable'; import type { Saga, SagaMiddleware } from 'redux-saga'; import { DUCKS_NAMESPACE } from '../config.js'; import { Bundle } from '../bundle.js'; import type { DucksMapObject } from '../duck.js'; export declare type BundlesMapObject<A extends DucksMapObject> = { [key in keyof A]: Bundle<A[key]>; }; declare class Ducks<A extends DucksMapObject> { protected readonly duckery: A; static VERSION: string; get store(): Store<any, import("redux").AnyAction> | undefined; protected _store?: Store; protected ducksNest: BundlesMapObject<A>; protected asyncMiddlewares: { epicMiddleware?: EpicMiddleware<any>; sagaMiddleware?: SagaMiddleware; }; protected get reducer(): Reducer<import("redux").StateFromReducersMapObject<import("./combine-duckery.js").DuckReducersMapObject<A>>, import("redux").ActionFromReducersMapObject<import("./combine-duckery.js").DuckReducersMapObject<A>>>; protected get middlewares(): Middleware[]; /** * Construct a `Ducks` manager for managing the Duck(s) * * @param duckery is a `DucksMapObject` which: * 1. key is the reducer key (namespace) * 2. value is a `Duck` instance */ constructor(duckery: A); /** * Return all Ducks */ ducksify(): BundlesMapObject<A>; /** * Return the Duck of `namespace` * @param namespace */ ducksify<NS extends keyof A>(namespace: NS): Bundle<A[NS]>; /** * Return the Bundle of `duck` * @param duck */ ducksify<NS extends keyof A>(duck: A[NS]): Bundle<A[NS]>; enhancer(): ReturnType<Ducks<A>['duckeryEnhancer']>; /** * 1. Add Ducks Reducers to Store * 2. Bind Store to Ducks */ protected duckeryEnhancer(): StoreEnhancer<{}, import("redux").StateFromReducersMapObject<import("./combine-duckery.js").DuckReducersMapObject<A>>>; /** * A convenience way to initialize your store with Ducks with default settings. * * `ducks.configureStore()` only supports creating a store with Ducks. * * If you want to create a store that with other `reducer` and `enhances` (or `middlewares`), * please use `createStore()` from `redux` module instead of this one. * * @param preloadedState */ configureStore(preloadedState?: { [DUCKS_NAMESPACE]: ReturnType<Ducks<A>['reducer']>; }): Store<{}, import("redux").AnyAction>; /** * Initialize ducks */ protected getRootEpic(): undefined | Epic; protected getRootSaga(): undefined | Saga; protected initializeDucks(store: Store<any, any>): void; } export { Ducks, }; //# sourceMappingURL=ducks.d.ts.map