Skip to content

Question: Handle action using a function instead of the type. #242

Open
@gotrecillo

Description

@gotrecillo

At the moment i have two types of reducers in my project. Ones using handleActions, but sometimes that is not enough because y respond to meta instead of the action type.

const shouldIAddDialog = action => !!(action.meta && action.meta.dialog)

export const dialogReducer = (state = [], action) => {
  if (shouldIAddDialog(action) {
    return [...state, action.meta.dialog];
  }

  if (action.type === actions.closeDialog.toString()) {
    return tail(state);
  }

  return state;
};

¿ would allow handleActions to respond to that custom conditions based on a function be a welcome feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions