Supose there are two mediators M1 and M2. There is also a proxy P that has a method list(path:String). This method will use a HTTPService to retrieve data. Once data is returned proxy P sends a notification. Both mediators M1 and M2 have interest on that notification.

Now, M1 retrieves the proxy P and calls list('fooo'). What is the best way to make sure M2 won't do a thing with the result notification?

Is it better to have a HTTPService for each mediator? Should both mediators check the notification body if they must ignore it?

Otherwise, you can use the type property of the note as a discriminator. This is basically the Asynchronous Token pattern. When you make a request you need a way to know what to do when the data comes back.

Have Proxy P's list method take an extra string param called 'invoker'.

Have Mediator M1 pass its name (this.getName()) to the list as the invoker param.

When Proxy P makes the remote call on HttpService, an AsyncToken instance is returned. Rather than ignoring that return, get it into a var and store the invoker name on it:

Code:

var token:AsyncToken = service.send();token.invoker = invoker;

Note that AsyncToken is a dynamic class you can add any property name to, so 'invoker' isn't magic.

When the result comes back, get not only the data from the ResultEvent but the token as well:

Code:

var token:AsyncToken=resultEvent.token;

That token has the invoker nam on it so when you send the notification:

If one view component needs to trigger a change in another view component that the first does not have a reference to and cannot send a bubbling event up the display list, then mediate. Both view components should have mediators. The first view component sends an event listened for by its mediator, that mediator sends a notification listened for by the second view component's mediator, who in turn sets some data or calls a method on the second view component.