Documentation
¶
Index ¶
Constants ¶
const StateRoute = "route"
StateRoute is the state key for the active route.
Variables ¶
This section is empty.
Functions ¶
func DebugLayoutWrapper ¶ added in v0.1.1
func DebugLayoutWrapper(debug bool)
DebugLayoutWrapper toggles debug logging for LayoutWrapper.
func DebugRegister ¶ added in v0.1.1
func DebugRegister(debug bool)
DebugRegister toggles debug logging for Register.
func DebugRouterView ¶ added in v0.1.1
func DebugRouterView(debug bool)
DebugRouterView toggles debug logging for RouterView.
Types ¶
type ActiveRoute ¶
ActiveRoute is the active route that is currently being displayed.
func GetActiveRoute ¶
func GetActiveRoute(ctx app.Context) ActiveRoute
GetActiveRoute gets the active route from the context.
func GetRoute ¶
func GetRoute(ctx app.Context, path string) *ActiveRoute
GetRoute returns the appropriate route from the registered routes.
If no matching route is found, then this returns nil.
func (ActiveRoute) ReadVariable ¶
func (a ActiveRoute) ReadVariable(name string, value *string) bool
ReadVariable retrieves the requested variable from the active route and stores it in the provided value.
This returns true if the variable was found and false if it was not.
type LayoutWrapper ¶
type LayoutWrapper struct {
app.Compo
// These need to be public so that the component is properly re-rendered.
LayoutComponent app.Composer
Meta map[string]string // TODO: Consider using `any` and having wrapper functions to get the values.
Route route.Route
RouteVariables map[string]string
PathVariablesFunctions []func(ctx app.Context, variables map[string]string)
}
LayoutWrapper is a wrapper around the desired component that handles top-level events to ensure that the component is properly updated.
func (*LayoutWrapper) OnMount ¶
func (c *LayoutWrapper) OnMount(ctx app.Context)
TODO: REMOVE THIS IF WE DON'T NEED IT
func (*LayoutWrapper) OnNav ¶
func (c *LayoutWrapper) OnNav(ctx app.Context)
func (*LayoutWrapper) OnUpdate ¶
func (c *LayoutWrapper) OnUpdate(ctx app.Context)
TODO: REMOVE THIS IF WE DON'T NEED IT
func (*LayoutWrapper) Render ¶
func (c *LayoutWrapper) Render() app.UI
type Route ¶
type Route struct {
Path string // The path of the route. This may optionally start with "/", and variables are of the form ":variable_name".
PathVariables func(ctx app.Context, variables map[string]string) // A function that will be called with the current path variables; additional work can be done to set others.
Component func() app.Composer // A function that will be called to create the component for the route.
Meta map[string]string // Metadata for the route.
Children []Route // Children routes (if any).
}
Route is a route that can be applied to the application.
This is analogous to a Vue router route.
type RouterViewComponent ¶
RouterViewComponent can be embedded in a layout component.
The router wil set the specific router view component with `SetComponent`, and the embedding component can call `RouterViewComponent` in its `Render` function to get the component that should be rendered in the router view.
func (*RouterViewComponent) OnUpdate ¶
func (v *RouterViewComponent) OnUpdate(ctx app.Context)
func (*RouterViewComponent) RouterView ¶
func (v *RouterViewComponent) RouterView() app.Composer
RouterView returns the router view comonent. Put this where you want the route component to be rendered.
In Vue, this would be the `<router-view>` component.
func (*RouterViewComponent) SetRouterView ¶
func (v *RouterViewComponent) SetRouterView(component app.Composer)
SetRouterView is used by the router to set the component that will be returned by `RouterView`.
This should not be called by anything but the router.
type RouterViewInterface ¶
RouterViewInterface is the interface that must be implemented in order for a component to be properly used in a route as a layout.
Instead of implementing this interface, a component should embed `RouterViewComponent`.