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]
Print
Author Topic: Request advice on cancelable commands  (Read 7239 times)
tspiva
Newbie
*
Posts: 2


View Profile Email
« on: April 13, 2009, 10:32:34 »

I was wondering if there is a way to send a notification or something to a command that's currently running.  Here's the setup of what I'm trying to do.

I have a project proxy which does all of the manipulation of the project elements in a work directory.  The user can then save off an archive which is a long running process.  To implement the archive, I created an archive command that is run and has to use things like setTimeout to keep the UI responsive (which really just updates a progress bar) while it's running.

I now need the ability to allow the user to "Cancel" the archive functionality.  However, I can't figure out a way to let the the command know that it needs to be canceled without using any hacks like setting something in the proxy or something.

I considered making a "helper" proxy to just handle saving and loading to/from an archive (they need to be able to cancel loading also) and setting a "cancel" attribute on that guy but I thought I would ask if anyone had any better ideas or if this should've been a helper proxy all along or any other suggestions/comments.

Thanks,
Tracy
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: April 13, 2009, 01:07:40 »

This is one of the reasons the Best Practices guide discourages the use of commands for async processes. They simply are not suited to the task.

However your proxy is. It should own the srevice, make the remote call, and have listeners on the service for progress as well as result and fault. If you're not displaying 'real' progress, then use an indeterminate progress bar at the view. Otherwise, broadcast progress notes as they are received at the proxy, and handle them at the mediator that owns the progress bar.

To cancel, simply retrieve the proxy and invoke a method that cancels the service call. QED.

-=Cliff>
Logged
tspiva
Newbie
*
Posts: 2


View Profile Email
« Reply #2 on: April 13, 2009, 01:14:33 »

Thanks for the quick reply.  I didn't see that in the best practices.. guess I should go back and read it again :)

I'll move it all to the proxy then.

Tracy
Logged
Pages: [1]
Print