SOLVED should I remove defcon glyph's observer?
RafaŁ Buchner last edited by
I want to track changes in the current glyph by using
RGlyph.addObserver(self, 'glyphHasChanged', 'Glyph.Changed). Is it necessary to remove this observer whenever the current glyph changes? Or does it unsubscribes by itself when the character in the Glyph Window changes?
I'm asking this question because I'm curious if I'm not adding unnecessary code to my tools.
yes, I think it’s a good idea to remove the observer in your code.
here’s what the defcon documentation says:
Don’t Forget removeObserver
The only real gotcha in this is that you must remove the observer from the observed object when the observation is no longer needed. If you don’t do this and the observed object is changed, it will try to post a notification to the object you have discarded. That could lead to trouble.
and here’s an example script in which the defcon
Glyph.Changedobserver is removed when the current glyph changes.