Core Architecture: Major System: Observers - UA-ScriptEase/scriptease GitHub Wiki
Observers allow us to send signals throughout our program that things are happening. Every custom class we create that can have observers has an ObserverManager<E>
object. The <E>
in is for the Observers that will be added to it. As of July 11, 2013, Observers do not need to extend any superclass, as many of them are different. Thus, ObserverManager
is merely a convenient way to store the observers without having to deal with Weak References.
This brings us to Weak References. We use Weak References so that our observers are disposed of when the object they are associated with or attached to is also disposed of. This prevents memory leaks in Java.