I would like to implement the MVC pattern in a difficult situation. The difficulty is that my models (objects generating events) are durable, and Views (event receivers) are short-lived. My problem is that thanks to the connection between them, long-lived models keep my short-lived looks alive, i.e. They cannot collect with garbage.
[MODEL] ------- <weak> -------> [VIEW]
|
<strong>
|
v
[CONTROLLER]
A way around this is to save the connections in the model in the WeakHashMap & View, Controller> file. This essentially allows you to view the type of garbage, and when that happens, WeakHashMap will also throw out the appropriate controller. That is, if the Controller does not contain a (strong) reference to the view, what it usually does. In this case, the views are kept alive through strong links until the model goes beyond.
[MODEL] ------- <weak> -------> [VIEW]
| ^
<strong> |
| |
v |
[CONTROLLER] ----------- <strong> ---/
Is there any other way to connect listeners to my models that will not contain my views (and controllers)?
: mdma: , . , , View, Controller View.