PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: barry on September 04, 2009, 07:46:17



Title: removing an Observer
Post by: barry on September 04, 2009, 07:46:17

Hi,

i've just started working with PureMVC and was wondering whether it's possible to remove a single observer from a Mediators notification list? I have a mediator that lists 3 notifications it wants to observe. Once a certain action has occurred i'd like to remove one of the notifications so that the mediator is no longer notified. Is this possible?

I've looked through the pureMVC classes and found that View has a removeObserver() public method, however, this isn't exposed by Facade. I'm presuming there's a reason behind this, so although i could just access view.removeObserver() by extending Facade, this may no be the right/best solution.

Any suggestions on the best way to deal with this would be appreciated.

Cheers


Title: Re: removing an Observer
Post by: puremvc on September 05, 2009, 06:35:00
By design, Mediators are long lived actors with fixed interests (like, say Charlton Heston :).

In this case, I'd have a Command respond to the transient interest retrieving the Mediator and executing a method on it rather than having the Mediator be interested. This way, when the Command has performed this one-shot duty, it can unregister itself by calling facade.removeCommand.

-=Cliff>


Title: Re: removing an Observer
Post by: barry on September 07, 2009, 03:25:02

Hi Cliff, thanks a lot for your response, that makes sense.