DEV Community

Discussion on: Moving Material Dialog Lifecycle Into NgRx Effects

Collapse
spierala profile image
Florian Spier

Cool Article! What about reusability? If you need another dialog which triggers another API call when saving... do you have to replicate all the Actions and the Effects?

Collapse
chandlerbaskins profile image
Chandler Baskins Author

Great question! Off the top of the head I can think of a way for re usability. You could pass in the Action that you want dispatched that triggers the API call to the payload of the saveDialog action. You would do this in the the openDialog Action. Or you could pass in some key and in the effect read the key and decide what Action to dispatch there. I think I like that one better so your not passing around actual actions although it makes it harder to change in the future. Definitely something to explore and refine