Skip to content

Commit

Permalink
feat(signal-store): common
Browse files Browse the repository at this point in the history
  • Loading branch information
mini-rx committed Oct 24, 2023
1 parent d5b551e commit ab70153
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 0 additions & 3 deletions libs/common/src/lib/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export interface StoreConfig<T> {
initialState?: T;
metaReducers?: MetaReducer<AppState>[];
extensions?: StoreExtension[];
combineReducersFn?: CombineReducersFn<AppState>;
}

// Used for the Redux API: Store.feature / StoreModule.forFeature
Expand All @@ -53,8 +52,6 @@ export type ReducerDictionary<T> = {
[p in keyof T]: Reducer<T[p]>;
};

export type CombineReducersFn<T> = (reducers: ReducerDictionary<T>) => Reducer<T>;

export type StateOrCallback<StateType> =
| Partial<StateType>
| ((state: StateType) => Partial<StateType>);
Expand Down
6 changes: 3 additions & 3 deletions libs/common/src/lib/reducer-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function createReducerManager() {
metaReducers: [],
};

let _reducer: Reducer<AppState>;
let reducer: Reducer<AppState>;

function _updateStateAndReducer(v: Partial<ReducerState>): void {
state = {
Expand All @@ -39,7 +39,7 @@ export function createReducerManager() {

const combinedMetaReducer: MetaReducer<AppState> = combineMetaReducers(state.metaReducers);
const combinedReducer: Reducer<AppState> = combineReducers(state.featureReducers);
_reducer = combinedMetaReducer(combinedReducer);
reducer = combinedMetaReducer(combinedReducer);
}

function setFeatureReducers(featureReducers: ReducerDictionary<AppState>) {
Expand Down Expand Up @@ -89,7 +89,7 @@ export function createReducerManager() {
addFeatureReducer,
removeFeatureReducer,
addMetaReducers,
getReducer: () => _reducer,
getReducer: () => reducer,
// Exported for testing
_updateStateAndReducer,
};
Expand Down

0 comments on commit ab70153

Please sign in to comment.