Asynchronous methods like fill() return an AsyncToken instance which you can use to add custom data to it (i.e. mark that ypu invoked a fill operation). In the result handling function the AsyncToken is available again, so you can add additional logic to your result handler, e.g.
 
private function resultHandler(event:ResultEvent):void
{
  switch (event.token.kind)
  {
    case "fill":
      ...
    case "delete":
      ...
  }
}
 
AsyncToken is a dynamic class so you can add whatever properties you like.
 
Another use case of AsyncToken is to add responders to it - this allows you to dynamically setup result/fault handling functions:
 
var token:AsyncToken = ds.fill(collection);
token.addResponder(new ItemResponder(resultFunction, faultFunction, "fill"));
 
and then
 
private function resultFunction(result:Object, token:Object):void
{
  // result usually is of type ResultEvent,
  // token is the third parameter passed to the ItemResponder constructor
  if (result is ResultEvent)
  {
   ...
  }
}
 
private function faultFunction(result:Object, token:Object):void
{
  // result usually is of type FaultEvent,
  // token is the third parameter passed to the ItemResponder constructor
  if (result is FaultEvent)
  {
   ...
  }
}
 
Dirk.

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jonas Windey
Sent: Wednesday, August 09, 2006 11:30 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Flex dataservices: fill vs asynctoken

Hi,

 

I’m new to flex dataservices (using WebORB), and I like to know what’s the difference between:

 

ds = new DataService("contact");

ds.fill(contacts);

 

and

 

ds = new DataService("contact");

var token:AsyncToken = AsyncToken(ds.fill(contacts));

token.kind = "fill";

 

Thanks!

Jonas

 

Jonas Windey

Web Developer

T. +32 3 216 86 47

 

Pixco Interactive Division

T. +32 3 216 86 40

F. +32 3 216 86 49

 

http://www.pixco.com

 

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to