You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2021/11/30 13:52:15 UTC

[royale-asjs] branch develop updated: Added IAsyncTask interface Thanks @dakom

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 738d582  Added IAsyncTask interface Thanks @dakom
738d582 is described below

commit 738d582eb6f86306d1e752d54d6df7df9aeb3a71
Author: Harbs <ha...@in-tools.com>
AuthorDate: Tue Nov 30 15:52:05 2021 +0200

    Added IAsyncTask interface Thanks @dakom
---
 .../org/apache/royale/utils/async/AsyncTask.as     |  4 +--
 .../apache/royale/utils/async/CompoundAsyncTask.as |  8 ++---
 .../org/apache/royale/utils/async/IAsyncTask.as    | 36 ++++++++++++++++++++++
 .../royale/utils/async/SequentialAsyncTask.as      |  6 ++--
 .../apache/royale/utils/async/HttpDownloadTask.as  |  2 +-
 .../apache/royale/utils/async/HttpUploadTask.as    |  2 +-
 6 files changed, 47 insertions(+), 11 deletions(-)

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 e54178e..493c366 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
@@ -32,7 +32,7 @@ package org.apache.royale.utils.async
   [Event(name="complete", type="org.apache.royale.events.Event")]
   [Event(name="failed", type="org.apache.royale.events.Event")]
   [Event(name="done", type="org.apache.royale.events.Event")]
-  public abstract class AsyncTask extends EventDispatcher
+  public abstract class AsyncTask extends EventDispatcher implements IAsyncTask
   {
     public function AsyncTask()
     {
@@ -136,7 +136,7 @@ package org.apache.royale.utils.async
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.9.6
      */
-    public function done(callback:Function):AsyncTask{
+    public function done(callback:Function):IAsyncTask{
       if(!doneCallbacks){
         doneCallbacks = [];
       }
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/CompoundAsyncTask.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/CompoundAsyncTask.as
index 661dfd8..84e90d7 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/CompoundAsyncTask.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/CompoundAsyncTask.as
@@ -65,7 +65,7 @@ package org.apache.royale.utils.async
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.9.6
      */
-    public function addTask(task:AsyncTask):void{
+    public function addTask(task:IAsyncTask):void{
       tasks.push(task);
     }
     
@@ -96,13 +96,13 @@ package org.apache.royale.utils.async
       _status = "pending";
       pendingTasks = [];
       for(var i:int=0;i<tasks.length;i++){
-        var task:AsyncTask = tasks[i];
+        var task:IAsyncTask = tasks[i];
         task.done(handleDone);
         pendingTasks.push(task);
         task.run();
       }
     }
-    private function handleDone(task:AsyncTask):void
+    private function handleDone(task:IAsyncTask):void
     {
       if(_status != "pending")
       {
@@ -120,7 +120,7 @@ package org.apache.royale.utils.async
           {
             while(pendingTasks.length)
             {
-              var pending:AsyncTask = pendingTasks.pop();
+              var pending:IAsyncTask = pendingTasks.pop();
               pending.cancel();
             }
             fail();
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
new file mode 100644
index 0000000..9636285
--- /dev/null
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/IAsyncTask.as
@@ -0,0 +1,36 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.utils.async
+{
+	public interface IAsyncTask
+	{
+		function done(callback:Function):IAsyncTask;
+		function run(data:Object=null):void;
+
+		function complete():void;
+		function fail():void;
+		function cancel():void;
+
+		function get status():String;
+		function get completed():Boolean;
+		function get failed():Boolean;
+		function get data():Object;
+	}
+
+}
\ No newline at end of file
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/SequentialAsyncTask.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/SequentialAsyncTask.as
index 77f2f18..17651ab 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/SequentialAsyncTask.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/async/SequentialAsyncTask.as
@@ -40,11 +40,11 @@ package org.apache.royale.utils.async
     {
       _status = "pending";
       pendingTasks = tasks.slice();
-      var task:AsyncTask = pendingTasks.shift();
+      var task:IAsyncTask = pendingTasks.shift();
       task.done(handleDone);
       task.run();
     }
-    private function handleDone(task:AsyncTask):void
+    private function handleDone(task:IAsyncTask):void
     {
       if(_status != "pending"){
         return;
@@ -66,7 +66,7 @@ package org.apache.royale.utils.async
 
       }
       if(pendingTasks.length){
-        var nextTask:AsyncTask = pendingTasks.shift();
+        var nextTask:IAsyncTask = pendingTasks.shift();
         nextTask.done(handleDone);
         nextTask.run(task);
       } else {
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpDownloadTask.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpDownloadTask.as
index 196ea13..3c52f0a 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpDownloadTask.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpDownloadTask.as
@@ -64,7 +64,7 @@ package org.apache.royale.utils.async
 			}
 		}
 		private var progressCallbacks:Array;
-    public function progress(callback:Function):AsyncTask{
+    public function progress(callback:Function):IAsyncTask{
       if(!progressCallbacks){
         progressCallbacks = [];
       }
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpUploadTask.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpUploadTask.as
index 8c04c82..d0eddb2 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpUploadTask.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/utils/async/HttpUploadTask.as
@@ -79,7 +79,7 @@ package org.apache.royale.utils.async
 			}
 		}
 		private var progressCallbacks:Array;
-    public function progress(callback:Function):AsyncTask{
+    public function progress(callback:Function):IAsyncTask{
       if(!progressCallbacks){
         progressCallbacks = [];
       }