public
Last active

Signals don't like the ... rest operator.

  • Download Gist
SignalAsyncToken.as
ActionScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
package com.pollensoft.pbt.twitter
{
import mx.core.mx_internal;
import mx.messaging.messages.IMessage;
import mx.rpc.AsyncToken;
use namespace mx_internal;
import org.osflash.signals.Signal;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.Fault;
public class SignalAsyncToken extends AsyncToken
{
public var responseSignal:Signal;
public var faultSignal:Signal;
public var responseIndex:int;
public var faultCodeIndex:int;
public var faultStringIndex:int;
public var faultDetailIndex:int;
public function SignalAsyncToken(message:IMessage=null, responseSignal:Signal=null, responseIndex:int=-1, faultSignal:Signal=null, faultCodeIndex:int=-1, faultStringIndex:int=-1, faultDetailIndex:int=-1)
{
super(message);
this.responseSignal = responseSignal;
this.responseIndex = responseIndex;
this.faultSignal = faultSignal;
this.faultCodeIndex = faultCodeIndex;
this.faultStringIndex = faultStringIndex;
this.faultDetailIndex = faultDetailIndex;
responseSignal.addOnce( responseHandler );
faultSignal.addOnce( faultHandler );
}
private function responseHandler( ... signalArgs ):void
{
var data:* = responseIndex >= 0 ? signalArgs[responseIndex] : null;
var event:ResultEvent = ResultEvent.createEvent( data, this );
mx_internal::applyResult(event);
}
private function faultHandler( ... signalArgs ):void
{
var faultCode:String = faultCodeIndex >= 0 ? signalArgs[faultCodeIndex] : "";
var faultString:String = faultStringIndex >= 0 ? signalArgs[faultStringIndex] : "";
var faultDetail:String = faultDetailIndex >= 0 ? signalArgs[faultDetailIndex] : "";
var event:FaultEvent = FaultEvent.createEvent(new Fault(faultCode, faultString, faultDetail), this);
mx_internal::applyFault( event );
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.