puremvc
|
|
« Reply #1 on: April 21, 2008, 05:47:51 » |
|
It all depends.You could simply have the WidgetCanvasMediator remove any child of the canvas before adding a new component when it responds to ADD_COMPONENT.
However that leaves the button and ots Mediator back in the other widget and no way to garbage collect them.
You'd probaly want all components that will be added to the canvas to implement an interface such as ICanvasComponent, say This interface would call for a remove method, which would send an event that its mediator would hear and trigger the REMOVE_COMPONENT sequence in the same way as clicking does now.
The WidgetCanvas would expose a method addComponent, that would go through its children and call remove on each ICanvasComponent before adding the new component.
Note I'm pushing that blackbox logic into the WidgetCanvas itself rather than the Mediator. -=Cliff>
|