Skip to content

Commit

Permalink
Merge pull request #49 from FreemRL/remove-getReducerApplicator-method
Browse files Browse the repository at this point in the history
removed method getReducerApplicator
  • Loading branch information
GabrielCTroia authored Oct 7, 2023
2 parents 75bd1d3 + d564b39 commit ac4cf97
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions libs/movex/src/lib/tools/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,29 +118,4 @@ export const createDispatcher = <
};

return { dispatch, unsubscribe: unsubscribeStateUpdates };
};

export const getReducerApplicator =
<
TState extends MovexState,
ActionsCollectionMap extends ActionsCollectionMapBase,
TReducerMap extends MovexReducerMap<
TState,
ActionsCollectionMap
> = MovexReducerMap<TState, ActionsCollectionMap>
>(
reducerMap: TReducerMap
) =>
<TActionType extends StringKeys<ActionsCollectionMap>>(
state: TState,
action: Action<TActionType, ActionsCollectionMap[TActionType]>
) => {
const reducer = reducerMap[action.type];

if (!reducer) {
return state;
}

// This is actually the next state
return reducer(state, action);
};
};

0 comments on commit ac4cf97

Please sign in to comment.