Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
July 21, 2017, 05:46:14 PM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: 1 [2]
Print
Author Topic: Events on GWT  (Read 17193 times)
fede
Newbie
*
Posts: 7


View Profile
« Reply #15 on: July 02, 2009, 05:37:30 AM »

Quote
The best practice guide (Page 13, Notification vs Events) shows that Notifications should be used to communicate between PureMVC actors Mediators, Commands and Proxies.

Yes this is also what i think so i've resolved this issue using the new event system of gwt 1.6 that make possible to define and fire custom event from view that are cached from the mediators:

ex:
Code:

public FriendshipsPageMediator() {
super(NAME,null);
....
proposeFriendshipView  = new ProposeFriendshipView();
proposeFriendshipView.addNotificationHandler(this);
                ....
}

@Override
public INotificationType<?>[] listNotificationInterests() {
return new INotificationType[]{
NotifiesUserConfiguration.LOADED_USER_PROFILE,
NotifiesFriendshipsModule._PROPOSED_FRIENDSHIP,
NotifiesFriendshipsModule._EDIT_FRIENDSHIP
};
}

@Override
public void handleNotification(INotification<?> notification) {
....
}

@Override
public void onNotificationEvent(NotificationEvent<?> event) {
if (event.is(NotifiesUserSearch.LOAD_USER_PUBLIC_PROFILE))
showProfileOf(event.as(NotifiesUserSearch.LOAD_USER_PUBLIC_PROFILE).body());
}


in the code above when the mediator instantiate it's view component register itself as a listener of NotificationEvents of the view.

so when the view fire a NotificationEvent its onNotificationEvent gets called,
now the mediator can decide if manage localli this events of send an application level Notification build from the NotificationEvent
Logged
Pages: 1 [2]
Print
Jump to: