Documentation
¶
Index ¶
- 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) Store(store flux.StoreInterface)
- func (t *Vapper) Watch(key interface{}, f func(done chan struct{}))
- type Context
- type Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
func (t *Vapper) Navigate(path string)
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) Store ¶
func (t *Vapper) Store(store flux.StoreInterface)
Types ¶
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