Pages: [1]   Go Down
  Print  
Author Topic: Observer + Singleton  (Read 1880 times)
November 10, 2012, 10:08:33 am
Hi all, wondering for an elegant solution for this:
A.cgr has an instance of a publisher. On initialization (a function which is called when A.cgr is loaded into the application) this publisher reference is copied to a singleton so it is globally accesible.

B.cgr  has exactly same behavior than A.cgr with its own publisher, etc.

How do you do in elegant way that A subscribe to B and vice-versa.
If A.cgr is loaded first, it can't subscribe to B.cgr cause B.cgr didn't initialized already so the reference at singleton is NULL.

Actually best solution I can find is, If this function called on start can be seen as a kind of constructor, adding another function which can be called anytime for "initialization".

Pages: [1]   Go Down
  Print  
 
Jump to: