Documentation ¶
Index ¶
- func Stop()
- type BaseView
- type Context
- type Handler
- type Vapper
- func (t *Vapper) Back()
- func (t *Vapper) CanNavigate(path string) bool
- func (t *Vapper) Config(cfg interface{})
- func (t *Vapper) Debug(message ...interface{})
- func (t *Vapper) Delete(key interface{})
- func (t *Vapper) Dispatch(action flux.ActionInterface) chan struct{}
- func (t *Vapper) Fail(err error)
- func (t *Vapper) InterceptLinks()
- func (t *Vapper) Log(message ...interface{})
- func (t *Vapper) Logf(format string, args ...interface{})
- func (t *Vapper) Navigate(path string)
- func (t *Vapper) NotFound(handler Handler)
- func (t *Vapper) Route(path string, handler Handler)
- func (t *Vapper) Start()
- func (t *Vapper) Store(store flux.StoreInterface)
- func (t *Vapper) Watch(key interface{}, f func(done chan struct{}))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseView ¶ added in v0.0.16
func (*BaseView) Render ¶ added in v0.0.16
func (t *BaseView) Render() vecty.ComponentOrHTML
type Context ¶
type Context struct { // Params is the parameters from the url as a map of names to values. Params map[string]string // Path is the path that triggered this particular route. If the hash // fallback is being used, the value of path does not include the '#' // symbol. Path string // InitialLoad is true iff this route was triggered during the initial // page load. I.e. it is true if this is the first path that the browser // was visiting when the javascript finished loading. InitialLoad bool // QueryParams is the query params from the URL. Because params may be // repeated with different values, the value part of the map is a slice QueryParams map[string][]string }
Context is used as an argument to Handlers
type Handler ¶
type Handler interface { Handle(ctx *Context) ReadyStateComplete() }
Handler is a function which is run in response to a specific route. A Handler takes a Context as an argument, which gives handler functions access to path parameters and other important information.
type Vapper ¶
type Vapper struct { // ShouldInterceptLinks tells the router whether or not to intercept click events // on links and call the Navigate method instead of the default behavior. // If it is set to true, the router will automatically intercept links when // Start, Navigate, or Back are called, or when the onpopstate event is triggered. ShouldInterceptLinks bool // ForceHashURL tells the router to use the hash component of the url to // represent different routes, even if history.pushState is supported. ForceHashURL bool // Verbose determines whether or not the router will log to console.log. // If true, the router will log a message if, e.g., a match cannot be found for // a particular path. Verbose bool // contains filtered or unexported fields }
func (*Vapper) Back ¶
func (t *Vapper) Back()
Back will cause the browser to go back to the previous page. It has the same effect as the user pressing the back button, and is just a wrapper around history.back()
func (*Vapper) CanNavigate ¶
CanNavigate returns true if the specified path can be navigated by the router, and false otherwise
func (*Vapper) Dispatch ¶
func (t *Vapper) Dispatch(action flux.ActionInterface) chan struct{}
func (*Vapper) InterceptLinks ¶
func (t *Vapper) InterceptLinks()
InterceptLinks intercepts click events on links of the form <a href="/foo"></a> and calls router.Navigate("/foo") instead, which triggers the appropriate Handler instead of requesting a new page from the server. Since InterceptLinks works by setting event listeners in the DOM, you must call this function whenever the DOM is changed. Alternatively, you can set r.ShouldInterceptLinks to true, which will trigger this function whenever Start, Navigate, or Back are called, or when the onpopstate event is triggered. Even with r.ShouldInterceptLinks set to true, you may still need to call this function if you change the DOM manually without triggering a route.
func (*Vapper) Navigate ¶
Navigate will trigger the handler associated with the given path and update window.location accordingly. If the browser supports history.pushState, that will be used. Otherwise, Navigate will set the hash component of window.location to the given path.
func (*Vapper) Route ¶
HandleFunc will cause the router to call f whenever window.location.pathname (or window.location.hash, if history.pushState is not supported) matches path. path can contain any number of parameters which are denoted with curly brackets. So, for example, a path argument of "users/{id}" will be triggered when the user visits users/123 and will call the handler function with params["id"] = "123".
func (*Vapper) Start ¶
func (t *Vapper) Start()
Start causes the router to listen for changes to window.location and trigger the appropriate handler whenever there is a change.
func (*Vapper) Store ¶ added in v0.0.6
func (t *Vapper) Store(store flux.StoreInterface)