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 d12e7e0  Fixed Router lifecycle for MXML
d12e7e0 is described below

commit d12e7e0b056365a9dda8f5f357c3709f63266edf
Author: Harbs <[email protected]>
AuthorDate: Wed Feb 12 02:04:19 2020 +0200

    Fixed Router lifecycle for MXML
---
 .../royale/org/apache/royale/routing/Router.as     | 23 ++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as
index e6f713d..aa113d8 100644
--- 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as
@@ -29,6 +29,7 @@ package org.apache.royale.routing
   import org.apache.royale.utils.MXMLDataInterpreter;
   import org.apache.royale.utils.sendStrandEvent;
   import org.apache.royale.utils.loadBeadFromValuesManager;
+  import org.apache.royale.utils.callLater;
   [DefaultProperty("beads")]
     /**
      *  Dispatched when the state is changed.
@@ -41,6 +42,16 @@ package org.apache.royale.routing
     [Event(name="stateChange", type="org.apache.royale.events.Event")]
 
     /**
+     *  Dispatched when bindings are initialized
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.7
+     */
+    [Event(name="initBindings", type="org.apache.royale.events.Event")]
+
+    /**
      * Router is a bead which automatically handles browsing history.
      * It could be attached to any strand, but typically it would be attached 
to Application or View
      * Listen to stateChange events to handle changes to browsing history and 
use setState and renderState for modifying the history.
@@ -69,12 +80,9 @@ package org.apache.royale.routing
                        {
                                window.addEventListener("hashchange", 
hashChangeHandler);
                        }
-      // If it's an Application, listen to applicationComplete
-      if(_strand is IInitialViewApplication)
-        listenOnStrand("applicationComplete",onInit);
-      //Otherwise listen to initComplete
-      else
-        listenOnStrand("initComplete",onInit);
+
+      // wait until the app is initialized. Calling onInit async soves this 
problem
+      callLater(onInit);
                }
     /**
      * Helper function to attach event listener without the need for casting
@@ -91,6 +99,9 @@ package org.apache.royale.routing
         for each (var bead:IBead in beads)
           addBead(bead);
       }
+      // needed for binding in MXML
+      dispatchEvent(new Event("initBindings"));
+
       COMPILE::JS
       {
         if(location.hash)

Reply via email to