Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass action args as meta to the factored actions #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

safonoi
Copy link

@safonoi safonoi commented Sep 13, 2017

Pass arguments of the action call for for queries persistence
E.g.

export default handleActions({
  [loadMessages.START]: (state, action) => {
    const conversationId = action.payload[0];

    return ({
      ...state,
      conversationId,
      messages: {
        ...state.messages,
        requested: false,
        requesting: true,
        error: null
      }
    });
  },
  [loadMessages.SUCCEEDED]: (state, action) => {
    const conversationId = action.meta[0];

    // the result should belong to the last request
    if (conversationId !== state.conversationId) {
      return state;
    }

    return {
      ...state,
      messages: {
        ...state.messages,
        result: action.payload,
        requested: true,
        requesting: false
      }
    };
  },

@safonoi safonoi changed the title pass action args as payload to the factored actions pass action args as meta to the factored actions Sep 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant