Canceling a command

jonnie's Avatar


14 Nov, 2010 06:33 PM

Let's say I have a long process involving a service that loads external data. Once the process starts, it might be a while before it completes, depending on how much data there is to grab, since only 100 rows of data are returned per page and I might have thousands of rows to go through. What's my best bet for canceling a command in case the user becomes impatient? At the moment, I have the service return a Promise with each call and the promise has a cancel method, but the only one who knows anything about the promise is the command. If I use a signal to execute the command, it's out on its own and I can't exactly track it down unless I add something like a getCommand method to the SignalCommandMap. Thoughts?

  1. 1 Posted by rickcr on 14 Nov, 2010 07:56 PM

    rickcr's Avatar

    I'd be curious to see how your Promise's cancel method works (just so I could learn.)

    Could you set a "somethingCancelled" property in a Model object? Then you can periodically check that property in your command doing the processing and of course you'd be able to update the Model "somethingCancelled" property from anywhere else within the app?

  2. Stray closed this discussion on 13 Feb, 2011 03:09 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac