 
 package weave.core
 {
+	import mx.core.mx_internal;
 	import mx.rpc.AsyncResponder;
 	import mx.rpc.AsyncToken;
 	import mx.rpc.events.FaultEvent;

	import weave.api.core.ICallbackCollection;
	import weave.api.core.IDisposableObject;
	import weave.api.core.ILinkableObject;
	import weave.api.getCallbackCollection;
	
	/**
	 * @author adufilie
	 */
	public class LinkablePromise implements ILinkableObject, IDisposableObject
	{
		public function LinkablePromise(invoke:Function, invokeParams:Array = null)
		{
			_invoke = invoke;
			_invokeParams = invokeParams;
			_callbackCollection = WeaveAPI.SessionManager.getCallbackCollection(this);
			_callbackCollection.addImmediateCallback(null, _immediateCallback);
			_callbackCollection.addGroupedCallback(null, _groupedCallback);
			_callbackCollection.triggerCallbacks();
		}
		
		private var _callbackCollection:ICallbackCollection;
		private var _invoke:Function;
		private var _invokeParams:Array;
		
		private var _pendingInvoke:Boolean;
		private var _asyncToken:AsyncToken;
		private var _selfTriggeredCount:uint = 0;
		private var _result:Object;
		private var _error:Object;
		
		public function get result():Object { return _result; }
		public function get error():Object { return _error; }
		
		private function _immediateCallback():void
		{

		private function _handleResult(event:ResultEvent = null, asyncToken:AsyncToken = null):void
		{
			// stop if asyncToken is no longer relevant
			if (_invalidated || _asyncToken != asyncToken)
				return;
			
			// no longer busy
