Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: 1 [2]
Print
Author Topic: Events on GWT  (Read 29007 times)
fede
Newbie
*
Posts: 7


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

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:
:

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