This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9cdcaa5670 Added exec to AsyncTask
9cdcaa5670 is described below

commit 9cdcaa5670bc6569f0d3322478911340bb8b2717
Author: Harbs <[email protected]>
AuthorDate: Wed Jan 22 16:32:41 2025 +0200

    Added exec to AsyncTask
---
 .../royale/org/apache/royale/utils/async/AsyncTask.as   | 17 +++++++++++++++++
 .../royale/org/apache/royale/utils/async/IAsyncTask.as  |  1 +
 2 files changed, 18 insertions(+)

diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/AsyncTask.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/AsyncTask.as
index 493c366b4d..92c17a5aae 100644
--- 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/AsyncTask.as
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/AsyncTask.as
@@ -143,6 +143,23 @@ package org.apache.royale.utils.async
       doneCallbacks.push(callback);
       return this;
     }
+    
+    /**
+     * exec encapsulates both `run` and `done` in a single call.
+     * The instance of the task is returned so that the task can be chained.
+     * This pattern enables code like this: `var task:AsyncTask = new 
AsyncTask().exec(callback);`
+     * The properties of the task should be examined in the callback to 
determine the results.
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.13
+     */
+    public function exec(callback:Function):IAsyncTask
+    {
+      run();
+      done(callback);
+      return this;
+    }
     public abstract function run(data:Object=null):void;
 
     /**
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/IAsyncTask.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/IAsyncTask.as
index 9636285208..9f3565ff14 100644
--- 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/IAsyncTask.as
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/IAsyncTask.as
@@ -21,6 +21,7 @@ package org.apache.royale.utils.async
        public interface IAsyncTask
        {
                function done(callback:Function):IAsyncTask;
+               function exec(callback:Function):IAsyncTask;
                function run(data:Object=null):void;
 
                function complete():void;

Reply via email to