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

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / General Discussion / Best practice: Send more notifications from commands or use mediator functions? on: July 12, 2011, 02:50:33
Hi,

If I have a command called 'SetReadyOnlyMode', is it OK for me to access public methods on mediators from that command and pass some properties? Or should I be firing another batch of notifications from that command to be picked up by the mediators?

The component views are disabled depending on some values in different proxies, so in my command I want to do this:
:
if (!userProxy.getAlwaysShowToolbars()){
   toolbarMediator1.hideView();
   toolbarMediator2.hideView();
}

if (userProxy.contactListContains(friendProxy.friendIDs)){
  friendListMediator.showView(friendProxy.friendIDs);
} else { // ... hide friendList ... }

 

Does this seem a good way to do it? Can commands 'directly' interact with mediators like this, and pass arguments etc.? Otherwise I'm worried I'll have bloated code as a result of too many notification string constants all with similar tasks.

Many thanks for any help!
2  Announcements and General Discussion / Architecture / Re: async commands, animations, fsm on: February 10, 2011, 07:48:18
Hi Cliff,

Thanks so much for your response :) I will take this onboard and build a trial app with the fsm implementation. I'll report back here on progress.

Thanks again!
3  Announcements and General Discussion / Architecture / async commands, animations, fsm on: February 04, 2011, 07:43:31
Hi guys,

I've been using PureMVC constantly for around 2 years, but often feel like I lack basic understanding of how to use this framework. I encounter problems with how to run asynch commands all the time. I've read every forum post on Asynch tokens, fsm, but I just don't get what I should do when waiting for animations or remote services to complete.

Here's my scenario:
1.  I click a button in one view that sends a notification to a macro command via that view's mediator.
2. said macro command sets off a sub command that asks several mediators to make adjustments to views, and asks one view in particular to commence a simple tween.
3. once that simple tween is complete, I want the execution of the rest of the subcommands to commence again.

That's basically it. Ideally I don't want to send another command saying that an animation is complete, and start off another batch of sub commands or whatever by calling a slightly different macro command that picks up where the last macro command left off. I just want some concept of delay to exist in a command chain and - ideally- to have some juncture where the feedback of an asynch token (or whatever) might determine which one of several sub commands to initiate next.

I would really appreciate any help here :) This is a daily struggle for me lately that I'm sure is easily overcome. Many thanks in advance for any help.
4  Announcements and General Discussion / Architecture / Re: How commands and mediators should interact on: April 19, 2010, 03:50:58
Thanks so much for taking the time to reply personally Cliff. Greatly appreciated.

I forgot to add that the project we are working on is located here should you like to check it out:
http://www.sparkol.com/

Thanks again.
5  Announcements and General Discussion / Architecture / How commands and mediators should interact on: April 14, 2010, 02:19:10
Hi guys. I've been using PureMVC solidly for a year and have had a heck of a ride with it. Ups and downs galore! I am very grateful for it and would like to thank all involved. I'm using it in 2 active projects.

I have scoured these forums, the manual, and read everything I can on the subject of PureMVC. So if I am asking something here that has been covered elsewhere - sorry, I tried my best!

In a moment I am going to describe a basic workflow that I encounter daily, and would really appreciate some guidance and feedback on where I'm going wrong or am making too much work for myself. The key questions I have are:

1. I am keen to pass arguments directly from commands to mediators through exposed public methods, but am under the impression that I should always use notifications to do this?

2. If I am sending a notification that is picked up by many different 'types' of mediators, would it not be more logical for that one notification to be registered with a single command, and then have that command send out more specific notifications to interested mediators?

On an aside - I also struggle sometimes with the notion that commands cannot retain information.

Onto my scenario. Say I have a document creation tool (like Word) written in Flex with PureMVC. In order to load a new document I need to do several things. This is the workflow at the moment:

1. user clicks a button to open a previously saved document.

2. the document thumbnail viewer mediator sends a notification asking if another document is about to be overwritten: GET_CANVAS_AVAILABLE.

3. The note is received by command A which directly asks the canvas mediator if its view is empty (and thus ready to receive a new document because there's no risk of overwriting anything).

4. Assuming it is empty, command A then sends another note back to thumbnail viewer: CANVAS_IS_AVAILABLE.

5. Thumbnail viewer then directly calls a public method in documentProxy and passes a document id so the doc can be retrieved from a remote DB.

6. the proxy then immediately sends another note to disable the application while the download is in progress (this is picked up by the application mediator): APPLICATION_DISABLE.

7.  documentProxy eventually downloads the document and sends another note: DOCUMENT_DOWNLOADED

8. the application mediator receives this note and re-enables the application.

9. The canvas mediator gets the same notification and loads the note body (html text) into the view.

10. Other mediators also receive the DOCUMENT_DOWNLOADED notification - say, a summary mediator, and a footer mediator (to show word count and whatnot).

11. The thumbnail viewer also receives the note and makes the thumbnail viewer invisible

12. And that's it - the workflow is complete.

Does it look like I am doing the right thing here? What would you guys do differently to optimise & centralise the flow of logic?

I'm sure this post is pretty dense so please ask me to expand if it will help.

Thanks again - I look forward to your response!
 
Pages: [1]