[Pas2js] pas2js router implementation

Michael Van Canneyt michael at freepascal.org
Wed Jan 31 09:48:17 CET 2018


Hi,

I have checked in a first version of a router implementation (unit webrouter).

The router is used commonly in single-page applications to navigate between
forms in the application, and uses the browser history mechanism to enable
the user to move back and forth between the forms with the back/forward
mechanism of the browser.

It can use a hash tag in the url or use the pushstate/popstate mechanism of
the history API, if available.

There are 2 demos available that demonstrate the router, they can be
configured to use the history api or the hash tag mechanism, see the
comments inside the program file.

Still on my TODO list: 
add a call to activate the route based on the current URL, to be used when
the application starts.

Feedback, comments welcome.

Michael.


More information about the Pas2js mailing list