Skip to content

Commit

Permalink
adding helper to display busy cursor on requests
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultz committed May 24, 2011
1 parent 3187d2c commit 3680aff
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/mesh/services/Request.as
Expand Up @@ -4,6 +4,8 @@ package mesh.services

import mesh.core.proxy.DataProxy;

import mx.managers.CursorManager;

public dynamic class Request extends DataProxy
{
private var _block:Function;
Expand Down Expand Up @@ -42,19 +44,31 @@ package mesh.services
{
if (!_isExecuting) {
_isExecuting = true;

showBusyCursor();
if (handler != null) {
addHandler(handler);
}

executeBlock(_block);
}
return this;
}

private var _useBusyCursor:Boolean;
public function useBusyCursor():Request
{
_useBusyCursor = true;
return this;
}

protected function fault(fault:Object):void
{
hideBusyCursor();
for each (var handler:Object in _handlers) {
handler.fault(fault);
}
_isExecuting = false;
}

protected function result(data:Object):void
Expand All @@ -64,6 +78,7 @@ package mesh.services

protected function success():void
{
hideBusyCursor();
for each (var handler:Object in _handlers) {
handler.success();
}
Expand All @@ -89,6 +104,20 @@ package mesh.services
{
block.apply(null, blockArgs());
}

private function showBusyCursor():void
{
if (_useBusyCursor) {
CursorManager.setBusyCursor();
}
}

private function hideBusyCursor():void
{
if (_useBusyCursor) {
CursorManager.removeBusyCursor();
}
}
}
}

Expand Down

0 comments on commit 3680aff

Please sign in to comment.