amcdnl/ngrx-actions

Support Multiple Actions

amcdnl opened this issue · 7 comments

Add the ability to support multiple actions in a store definition.

@Store({ ... })
export class MyStore {
   @Action(Action1, Action2)
   myfn() { ... }
}

Interested to move to this util class but this is a common use case in our codebase. Following along for status.

Done in 1.1.0

Hi, I have a question that is related to this. I am trying to get ngrx-actions and ngrx-forms working together. For ngrx-forms validation, the validation functions are triggered on any action (no action type check), like:

export function appReducer(state = initialState, action: Action): AppState {
  const myForm = myFormReducer(state.myForm, action);
  if (myForm !== state.myForm) {
    state = { ...state, myForm };
  }

  switch (action.type) {
    case 'some action type':
      // modify state
      return state;

    default: {
      return state;
    }
  }
}

I wonder if there's a way to implement this in the @Store, since @Action has to be given ActionTypes to fire up.

so in the end importing the Action classes from ngrx-forms and using spread operator to pass them to @Action method worked fine.

@danielpiedra - I'm actually working on a forms solution, should have something early next week.

@amcdnl awesome news, can't wait to check it out. I'm still on the early stages of setting up a current project so refactoring won't be a headache :)