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
WindeySent: Wednesday, August 09, 2006 11:30 AMTo:
flexcoders@yahoogroups.comSubject: [flexcoders] Flex dataservices:
fill vs asynctoken
Hi,
Im new to flex dataservices
(using WebORB), and I like to know whats 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
Visit your group "flexcoders" on the web.
To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___