When the user visits a URL in their browser, an Erstwhile application goes through the following steps:
- Boots: This only happens when the page first loads, where the pre-compiled routes and templates are loaded into the application. Subsequent page loads use this cached information.
- Check the path in the routing table: The framework attempts to look up the path in the routing table. Assuming it finds it…
- Clears the page scope: The framework empties the page scope, getting it ready for the next page to load.
- Run the controller’s
preAction: If one is provided. - Run the specified route action: This is the big one, and can include things like the following.
- Setting Scoped Variables needed by the view layer to properly render the page.
- Defining event handlers that can be used within the views.
- Handling query string arguments that can change page behavior.
- Accessing data via the model layer to either do lookups or updating operations.
- Registering deferred functions that need to be run after the DOM is rendered.
- Run the controller’s
postAction: If one is provided. - Renders the ErML layout: If necessary. If the layout hasn’t changed, it keeps it as is.
- Renders the ErML page view: Based on the controller and action name.
- Registers the
ErstwhileComponents present in the layout and page. - Initializes the
ErstwhileComponents. - Registers the listeners for the Scoped Variables.
- Runs the deferred functions.
Steps 2-13 are repeated whenever a user goes to a new URL, which typically happens through the application’s redirect() method.