MrWolfZ / ngrx-forms

Enhance your forms in Angular applications with the power of ngrx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handling MarkAsSubmittedAdtion within several effects

erzet opened this issue · comments

commented

This one might be obvious, but nevertheless, I'd like to ask how to resolve a problem that I've encountered.

So I'm having two Effects that are triggered by MarkAsSubmittedAction declared in two modules, and once I load both modules in a lazy manner, I end up having both triggered. So the first solution that comes to my mind is just to filter for form id within the Effect pipe. My question - is there any other way to handle this case? Or it's just an ngrx thing and I should live with that and do the filtering? Maybe there's some better way - like a smart way of unloading already merged effects?

Any help much appreciated!

Can i ask are your 2 effects the same effect class that is being used in 2 different lazy-loaded modules or 2 different effect classes?

But if its 2 effects, 2 createEffect() calls, then i don't think there's a way around it and filtering would be needed.

In my experience with ngrx-forms so far, when using with @ngrx/effects, there seem to be a need to filter using the controlId since all the actions are the same. I've made a suggestion/request (#250 ) for some kind of handler in ngrx-forms to be used in ngrx/effects but no response yet.

Indeed, you will always need to filter any actions based on the controlId due to how ngrx works.