DEV Community

loading...

Discussion on: Angular Architecture: How to use Command Pattern to manage large amount of context menu actions

Collapse
marekozw profile image
..

Hi! Very interesting piece, congrats.

A question. You said "istead of JobStartAction.build() we have to inject services via this.injector.get(JobStartAction), because our action definitions are in fact global services."

Isn't it possible to just inject them using constructor?

Have a great day!

Collapse
humberd profile image
Maciej Sawicki Author

Hey, absolutely! You can inject them in the constructor, however, when we have a very large amount of actions then the constructor would be enormous and would take up the entire screen. So having only one service injected via constructor and then inline injecting the actions makes the class more readable.

Collapse
marekozw profile image
..

Thanks for clearing that out! I agree, code is more elegant that way.