I have a manager class which initializes child classes with some dependencies. The problem with the dependencies is that in some instances a new object for them is created. This particular part is out of my control and cannot be updated to reuse the same reference.
My manager class receives an event which contains the new object and I update my manager to use that. The same dependency is used in the child classes as well and now I have to update them there as well. I want to check if there’s a way through which I can write a lambda function in my manager class and pass that function to the child classes such that the reference to the object in child classes is always the latest one? Something that can prevent the hassle of maintaining/updating references in all the classes.
I tried adding a lambda function and passing it to the child classes but its not allowing me to call the functions of the value returned by the lambda function.