-
Notifications
You must be signed in to change notification settings - Fork 1
Pages
See Also: about-pages
Page
s are, effectively, controller-classes which are associated with route descriptions, and are instantiated when that route is "taken". For instance, if I, in my main
Application, write:
class MyApp extends tannus.Application {
// ...
/**
* Invoked by the constructor
**/
public function beforeStart():Void {
this.route('*', null, pages.Home);
}
}
and have a pages package, with a Home class that reads:
class Home extends tannus.core.Page {
public function new(route_taken : tannus.core.Route):Void {
super( route_taken );
trace( "I have been instantiated! :D" );
}
}
Upon the invocation of MyApp
's start
method, you will be able to see "I have been instantiated! :D"
printed to the console.
When you called your Application's route
method, you gave it a route-description string, and a Page
class to associate with the created Route
Object. When the Application was "started", it invoked it's routing system and for every Route
that accurately described the current URL, it created a new instance of the Page
class associated with that Route
. In the case described above, the only route we defined referenced the Home
class, and would match any URL, so no matter what, our Home
class gets instantiated.