Loader
The Loader
interface in torque
is a ubiquitous interface in the Controller API that enables your route controller to handle incoming HTTP GET requests. Its responsibility is to load a ViewModel
that will then be rendered to the response.
The generic constraint T
is the ViewModel
type that the Loader
is expected to return. Providing this enable torque to do some pretty cool things, like static type checking and code generation.
Note that the generic constraint
T
is also shared by theRenderer
interface. Refer to the Renderer documentation for more information.
Implementation
Hooks
Typically used in a Loader
, hooks can pass data to the Load
method from other parts of the request stack, such as middlewares, outlet handlers or plugins.
The torque framework offers a series of built in hooks that can be found on the Hooks page. A basic example is the torque Mode
hook, which can be used to determine the current runtime environment.