puremvc
|
|
« Reply #1 on: October 06, 2008, 06:44:15 » |
|
Ok here's the poor man's note cancel:
If the command happens to be registered in the facade's initializeController method then you can be sure its the first observer to be notified.
This means the command gets a chance to modify the notification before the others get it, which means you could do something like use the type property of the note to indicate the result of the command's evaluation, and have the mediators act (or not) depending. Or you could create a custom note class with a cancel prop.
But that smells because the subsequent notifications happen, eating up cycles, and you have to have logic in the mediators to keep them from acting on a 'cancelled' note.
What you really want to do is have two notifications. The first one triggers the command and if the command wants further processing to happen, it sends the second note.
For instance, a note called USER_GESTURE is sent and the command looks at it and determines if it contains a valid gesture. If so, it sends PROCESS_VALID_GESTURE, whiche the mediators all handle as need be.
-=Cliff>
|