Refactor Saves to Use Closures
Reported by Dan Schultz | January 17th, 2011 @ 12:18 AM | in 0.3.0
Refactor save operations to not rely on the
createSave()
and createDelete()
methods.
All this logic should be contained within save()
and
delete()
. In addition, this would allow us to remove
the whole operations API, which is one less thing people have to
worry about and learn.
We should be able to accomplish this by creating a object that executes a closure function.
public class Entity
{
public function save(validate:Boolean):AsyncToken
{
var token:AsyncToken = new AsyncToken();
var closure:Function = function():void
{
if (validate && isInvalid()) {
token.fault();
}
var resultHandler:Function = function(result:ResultEvent):void
{
token.result(result);
}
var faultHandler:Function = function(fault:FaultEvent):void
{
token.fault(fault);
}
var adaptorToken:AsyncToken = isNew ? adaptor.create([this]) : adaptor.update([this]);
adaptorToken.addResponder(new AsyncResponder(resultHandler, faultHandler));
}
return token;
}
}
Comments and changes to this ticket
-
Dan Schultz January 20th, 2011 @ 02:02 AM
- Milestone changed from 0.1.0 to 0.2.0
- Milestone order changed from 8 to 0
-
Dan Schultz March 17th, 2011 @ 08:08 AM
- State changed from new to open
-
Dan Schultz April 6th, 2011 @ 05:11 AM
- Milestone changed from 0.2.0 to 0.3.0
- Milestone order changed from 4 to 0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Mesh is an open-source persistence framework for Adobe Flex. It is designed to make the persistence of your application's model easier. Mesh provides the mechanisms for defining the associations between your model's entities, tracking which objects need to be saved, and mapping your entities to backend services.
<p>
<strong>Wiki</strong>
The Mesh wiki is hosted on GitHub at <a href="https://github.com/danschultz/mesh/wiki">https://github.com/danschultz/mesh/wiki</a>.
</p>
<p>
<strong>Source Code</strong>
Mesh is hosted on GitHub at <a href="http://github.com/danschultz/mesh">http://github.com/danschultz/mesh</a>.
</p>