I'm working with Angular 8 and NgRx 8, is it possible create an action with optional payload? I'm trying to do something like:
export const MyAction = createAction('[Action ] MyAction', props<{ prop?: string }>());
but unfortunately doesn't work. Could you help me?
It is possible to make the keys in the payload optional, but not the payload object itself. So the solution can be like this, where we want the error in the payload object to be optional.
export const listenForFeatureFailure = createAction(
'[Feature] listen for feature Failure',
props<{ error?: any }>()
);
And in your effects you can call it with or without the error
...
ProductSubscriptionActions.listenForFeatureAccessUpdatedFailure({error});
// or
ProductSubscriptionActions.listenForFeatureAccessUpdatedFailure({});