WxAaRoNxW
Explore posts from servers❔ Am I doing event subscription correctly?
I have 2 singleton classes
SingletonA, working mostly alone and has events
and the other, SingletonB can also work alone but in my code, needs to rely on the A's events so that it functions.
both are initialized at the same time, both are uninitialized at the same time
on initialization, SingletonB subscribes to SingletonA
and on uninitialization SingletonB unsubscribes to SingletonA
but there are times when SingletonA unitializes first so the Instance reference is set to null leaving SingletonB's uninitialization throwing an exception.
do I just slap a null condition before unsubscribing or is there a better way?
4 replies