I am impressed by the way you think and just code it , how can i become pro like you ? :)
@shubhamgohel9064 Жыл бұрын
That's a good one, but can you please do with the DI? Because, currently you are passing the next handler directly but what if I have 3 or 4 handlers? Like H1 - H2 - H3 - H4. How should I manage this with DI? Also, what if each handler takes different types of arguments? The best example is a restaurant menu.
@SingletonSean Жыл бұрын
Good questions! I think even with DI, you'd have to manually resolve and pass in each handler, especially since they all implement the same interface. Also, I would usually use this pattern if all the handlers take the same arguments. This makes the chain flexible, where we can re-order the different handlers without worrying about type issues.