0 Replies Latest reply on Aug 28, 2007 6:57 AM by Nixy

    Listener VS simple Object.function call

    Nixy Level 1
      I know that listeners allow multiple Class to listen to one object. In the other way if there is only one object that must listen or react when an event is triggered, we can simply use the object reference and by that reference calling the function. For example if we have 2 Classes A & B.

      First Option : Class A is the object that dispatch an event when a transition is completed. CLass B can listen all events from Class A and the execute a function when the Class A transition is done.

      Second Option : Class A has a reference of Class B. When Class A transition is completed, Class A use the Class B reference to execute a function in the Class B.

      The 2 options does the same thing. The only diffrence is that in the first option, many objects can react to the end of the Class A transition.

      What I'd like to know, is what is the best way. I mean, If I only have one Object that listen to the Class A Events. Is that a better way to use object reference? Does the Listener are slower to execute instead of a function call from a reference? Does...

      Listeners take more code to execute, must be removed when the Class is removed. May be I there is more to know then that.

      Any opinion or suggestion?