I am currently working with a reducer function that aggregates values in a specific way.
The first argument is the aggregated value, while the second argument represents the next value. This function reduces over the same reaction
argument, aggregating the state$
value. Each time it runs, a new aggregated value is produced.
/**
* Applies all the reducers to create a state object.
*/
function reactionReducer(reaction: ReactionObject): ReactionObject {
let state$ = reactionDescriptionReducer({}, reaction);
state$ = reactionDisabledReducer(state$, reaction);
state$ = reactionIconReducer(state$, reaction);
state$ = reactionOrderReducer(state$, reaction);
state$ = reactionStyleReducer(state$, reaction);
state$ = reactionTitleReducer(state$, reaction);
state$ = reactionTooltipReducer(state$, reaction);
state$ = reactionVisibleReducer(state$, reaction);
return state$;
}
const state = reactionReducer(value);
Although this setup works, I'm looking for a more flexible solution. I believe RamdaJS could provide a way to achieve this.
const state = R.????({}, value, [reactionDescriptionReducer
reactionDisabledReducer,
reactionIconReducer,
reactionOrderReducer,
reactionStyleReducer,
reactionTitleReducer,
reactionTooltipReducer,
reactionVisibleReducer]);
As someone new to RamdaJS, I appreciate your patience with what may be a beginner question.
How can I utilize RamdaJS to run a chain of reducers effectively?