juliankrispel / Pollock

A canvas-based application which paints by itself.
2 stars 1 forks source link

Why are we calling the subscriber this way? #31

Open juliankrispel opened 10 years ago

juliankrispel commented 10 years ago

The name with which we register a subscriber -> obj.constructor.name+"_"+property seems unintuitive. Why not just use the constructors name on its own?

ulikk commented 10 years ago

There is a specific reason for this, the 'unintuitive' behaviour stems from the fact that if you use only the constructor, all members of an object will listen to the same channel. If you use only the property, all similarly named properties of different objects will listen to the same channel. Whats still problematic in this naming scheme is that properties of multiple instances of a class will bind to the same channel. PublishSubscriber uses this behaviour as we use published variables in this way application side (e.g. brushMinSize/brushMaxSize properties of all Movements will bind to the same channel). This might change in the future if we need channels 'per instance'.