Skip to content

Commit

Permalink
Updated URLRequestHelper and IURLRequestHelper to return the URLLoade…
Browse files Browse the repository at this point in the history
…r rather than the URLRequest in order to better facilitate chaining.
  • Loading branch information
bclinkinbeard committed Nov 30, 2010
1 parent bccdb65 commit e213043
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/org/swizframework/utils/services/IURLRequestHelper.as
@@ -1,11 +1,12 @@
package org.swizframework.utils.services
{
import flash.net.URLLoader;
import flash.net.URLRequest;

public interface IURLRequestHelper
{
function executeURLRequest( request:URLRequest, resultHandler:Function, faultHandler:Function = null,
progressHandler:Function = null, httpStatusHandler:Function = null,
eventArgs:Array = null ):URLRequest
eventArgs:Array = null ):URLLoader
}
}
7 changes: 4 additions & 3 deletions src/org/swizframework/utils/services/SwizURLRequest.as
Expand Up @@ -40,6 +40,8 @@ package org.swizframework.utils.services
*/
public class SwizURLRequest
{
public var loader:URLLoader;

/**
*
* @param request
Expand All @@ -54,13 +56,12 @@ package org.swizframework.utils.services
faultHandler:Function = null, progressHandler:Function = null,
httpStatusHandler:Function = null, eventArgs:Array = null )
{

var loader:URLLoader = new URLLoader();
loader = new URLLoader();

loader.addEventListener( Event.COMPLETE, function( e:Event ):void
{
// we could apply the result directly but from the current knowledge applying the event itself
// seems more flexible. This may change in the future if we don't see any necessarity for this.
// seems more flexible. This may change in the future if we don't see any necessity for this.

if( eventArgs == null )
{
Expand Down
6 changes: 3 additions & 3 deletions src/org/swizframework/utils/services/URLRequestHelper.as
Expand Up @@ -16,6 +16,7 @@

package org.swizframework.utils.services
{
import flash.net.URLLoader;
import flash.net.URLRequest;

import org.swizframework.core.ISwiz;
Expand All @@ -33,16 +34,15 @@ package org.swizframework.utils.services
/** Delegates execute url request call to Swiz */
public function executeURLRequest( request:URLRequest, resultHandler:Function, faultHandler:Function = null,
progressHandler:Function = null, httpStatusHandler:Function = null,
eventArgs:Array = null ):URLRequest
eventArgs:Array = null ):URLLoader
{

// use default fault handler defined for swiz instance if not provided
if( faultHandler == null && _swiz.config.defaultFaultHandler != null )
faultHandler = _swiz.config.defaultFaultHandler;

var dynamicURLRequest:SwizURLRequest = new SwizURLRequest( request, resultHandler, faultHandler, progressHandler, httpStatusHandler, eventArgs );

return request;
return new SwizURLRequest( request, resultHandler, faultHandler, progressHandler, httpStatusHandler, eventArgs ).loader;
}
}
}

0 comments on commit e213043

Please sign in to comment.