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 46cce4a Added IRouter interface 46cce4a is described below commit 46cce4a64afb948ee4e497f04c99e35c4cb94520 Author: Harbs <ha...@in-tools.com> AuthorDate: Tue Apr 21 15:02:12 2020 +0300 Added IRouter interface --- .../org/apache/royale/routing/BrowserRouter.as | 7 ++-- .../royale/org/apache/royale/routing/HashRouter.as | 3 +- .../routing/{LinkInterceptor.as => IRouter.as} | 37 +++------------------- .../org/apache/royale/routing/LinkInterceptor.as | 6 ++-- .../org/apache/royale/routing/PathRouteBead.as | 6 ++-- .../org/apache/royale/routing/RouteToComponent.as | 2 +- .../org/apache/royale/routing/RouteToParameters.as | 6 ++-- .../royale/org/apache/royale/routing/Router.as | 2 +- .../org/apache/royale/routing/SetRouteTitle.as | 6 ++-- 9 files changed, 26 insertions(+), 49 deletions(-) diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/BrowserRouter.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/BrowserRouter.as index d7b9085..8fa9dbc 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/BrowserRouter.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/BrowserRouter.as @@ -52,16 +52,19 @@ package org.apache.royale.routing [Event(name="initBindings", type="org.apache.royale.events.Event")] /** - * Router is a bead which automatically handles browsing history. + * BrowserRouter 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. * The state of the router can be modified before committing the state changes. + * The difference between HashRouter and BrowserRouter is that HashRouter uses the location hash which is only the section from "#" and on. + * BrowserRouter uses path routes which are indistinguishable from normal urls. + * Both Router implementations can use a hash for scroll positioning beads. * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion Royale 0.9.8 */ - public class BrowserRouter extends Strand implements IBead, IMXMLDocument + public class BrowserRouter extends Strand implements IRouter, IBead, IMXMLDocument { public function BrowserRouter() { diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/HashRouter.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/HashRouter.as index ed322f0..a290cf9 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/HashRouter.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/HashRouter.as @@ -58,12 +58,13 @@ package org.apache.royale.routing * The state of the router can be modified before committing the state changes. * The difference between HashRouter and BrowserRouter is that HashRouter uses the location hash which is only the section from "#" and on. * BrowserRouter uses path routes which are indistinguishable from normal urls. + * Both Router implementations can use a hash for scroll positioning beads. * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion Royale 0.9.8 */ - public class HashRouter extends Strand implements IBead, IMXMLDocument + public class HashRouter extends Strand implements IRouter, IBead, IMXMLDocument { public function HashRouter() { diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/LinkInterceptor.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/IRouter.as similarity index 55% copy from frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/LinkInterceptor.as copy to frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/IRouter.as index 585c78c..2898431 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/LinkInterceptor.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/IRouter.as @@ -18,40 +18,13 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.royale.routing { - import org.apache.royale.core.Bead; import org.apache.royale.core.IStrand; - import org.apache.royale.events.Event; - public class LinkInterceptor extends Bead + public interface IRouter { - public function LinkInterceptor() - { - - } - - /** - * @royaleignorecoercion org.apache.royale.routing.Router - */ - private function get host():Router{ - return _strand as Router - } - - override public function set strand(value:IStrand):void - { - _strand = value; - COMPILE::JS - { - document.addEventListener('click', interceptClickEvent); - } - } - /** - * If requireHash is true, any link that does not start with hash will be handled by a browser redirect - */ - public var requireHash:Boolean = false; - private function interceptClickEvent(ev:Event):void - { - //TODO find the link target and handle the click event - trace(ev); - } + function get routeState():RouteState; + function set routeState(state:RouteState):void; + function get host():IStrand; + function setState():void; } } \ No newline at end of file diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/LinkInterceptor.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/LinkInterceptor.as index 585c78c..10440d9 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/LinkInterceptor.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/LinkInterceptor.as @@ -30,10 +30,10 @@ package org.apache.royale.routing } /** - * @royaleignorecoercion org.apache.royale.routing.Router + * @royaleignorecoercion org.apache.royale.routing.IRouter */ - private function get host():Router{ - return _strand as Router + private function get host():IRouter{ + return _strand as IRouter } override public function set strand(value:IStrand):void diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/PathRouteBead.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/PathRouteBead.as index a041813..de337f4 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/PathRouteBead.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/PathRouteBead.as @@ -30,10 +30,10 @@ package org.apache.royale.routing } /** - * @royaleignorecoercion org.apache.royale.routing.Router + * @royaleignorecoercion org.apache.royale.routing.IRouter */ - protected function get host():Router{ - return _strand as Router + protected function get host():IRouter{ + return _strand as IRouter } override public function set strand(value:IStrand):void { diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToComponent.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToComponent.as index 6bf7bec..ec1f9b4 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToComponent.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToComponent.as @@ -23,7 +23,7 @@ package org.apache.royale.routing import org.apache.royale.core.IStrand; [DefaultProperty("routes")] /** - * RouteToComponent is a bead designed for Router + * RouteToComponent is a bead designed for IRouter * One or more routes should be assigned to the bead */ public class RouteToComponent extends PathRouteBead diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToParameters.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToParameters.as index 8d4d5a8..e5703f3 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToParameters.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToParameters.as @@ -31,10 +31,10 @@ package org.apache.royale.routing } /** - * @royaleignorecoercion org.apache.royale.routing.Router + * @royaleignorecoercion org.apache.royale.routing.IRouter */ - private function get host():Router{ - return _strand as Router + private function get host():IRouter{ + return _strand as IRouter } override public function set strand(value:IStrand):void { 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 55335a5..91028c3 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 @@ -63,7 +63,7 @@ package org.apache.royale.routing * @productversion Royale 0.9.7 * @deprecated */ - public class Router extends Strand implements IBead, IMXMLDocument + public class Router extends Strand implements IRouter, IBead, IMXMLDocument { public function Router() { diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/SetRouteTitle.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/SetRouteTitle.as index 081fd05..c06f59c 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/SetRouteTitle.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/SetRouteTitle.as @@ -29,10 +29,10 @@ package org.apache.royale.routing } /** - * @royaleignorecoercion org.apache.royale.routing.Router + * @royaleignorecoercion org.apache.royale.routing.IRouter */ - protected function get host():Router{ - return _strand as Router + protected function get host():IRouter{ + return _strand as IRouter } override public function set strand(value:IStrand):void