Exposed a method to allow users to batch property set requests into a

dobj transaction. Thanks to mdb for the idea of accepting a function to run
for the batch, rather than exposing startTransaction() and commitTransaction()
directly.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@317 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Ray Greenwell
2007-06-18 19:33:02 +00:00
parent 5116ab7089
commit bdef34eb69
2 changed files with 43 additions and 0 deletions
@@ -265,6 +265,29 @@ public class EZGameControl extends BaseControl
callEZCode("testAndSetProperty_v1", propName, newValue, testValue, index);
}
/**
* Execute the specified function as a batch of commands that will be sent to the server
* together. This is no different from executing the commands outside of a batch, but
* may result in better use of the network and should be used if setting a number of things
* at once.
*
* Example:
* _ctrl.doBatch(function () :void {
* _ctrl.set("board", new Array());
* _ctrl.set("scores", new Array());
* _ctrl.set("captures", 0);
* });
*/
public function doBatch (fn :Function) :void
{
callEZCode("startTransaction");
try {
fn();
} finally {
callEZCode("commitTransaction");
}
}
/**
* Get the names of all currently-set properties that begin with the specified prefix.
*/