VContainer icon indicating copy to clipboard operation
VContainer copied to clipboard

Implementing command pattern with Vcontainer

Open shaked-okami opened this issue 1 year ago • 1 comments

The way i see it right now there are two possible ways to do this, in both way there would be a factory that would create the commands the difference is how we inject dependencies to the actual command:

  1. Registering the factory itself then in whatever class we will use to create a new command we will inject the dependencies of the command to that class and pass it to the command.

  2. Registering a callback that would create the command and use IObjectResolver to resolve and forward whatever dependencies the command would need.

However if we take approach 1 I fear it could lead to big loading times of the scope, while using approach 2 would result in longer runtime when creating a command since we need to directly resolve it.

How do you suggest to implement this?

shaked-okami avatar Jul 31 '23 12:07 shaked-okami

You can try this: https://github.com/Bezarius/UMediator

Bezarius avatar Sep 20 '23 09:09 Bezarius

The performance of both forms is probably not much different. In general, the bounds are more correct if you rely only on the Factory rather than directly on the IObjectResolver. So we should consider 1 first. But it might depend on implementation details.

hadashiA avatar Jun 19 '24 03:06 hadashiA