@curi/interactions
v2.0.1
GitHub RepoNPM PackageAbout
The @curi/interactions
package provides a number of functions for interacting with Curi routes.
Installation
UMD scripts script are also available through Unpkg. You can access the package's exports using window.CuriInteractions
.
API
pathname
An interaction function to generate a pathname string for a route.
If the route requires an params, they should be provided as the second argument to the function call.
Arguments
route
The route to generate a pathname string for.
params
An object of params used to generate the pathname. If the route and/or any of its ancestor routes require params, then this argument must be provided.
active
An interaction function that uses a response object to determine if a route is "active".
The interaction requires two arguments, the first being the route data and the second being a response object.
Arguments
route
The route to determine if it is active.
response
A response object emitted by the router.
options
An object with additional options
params
If the route requires params, these are the params that should be compared against the response's params.
partial
When true (defaults to false), a route that is an ancestor of the response's route can be considered active if its params match the response's params.
components
A function to compare the other location components (hash
and query
) against the response's location.
ancestors
An interaction function to get the ancestors of a route.
The interaction returns the public route data for each of the route's ancestors. The first item in the array is the root-most ancestor, while the last item in the array is the route's parent.
Arguments
route
The route to get the ancestors of.
prefetch
A function that will call a route's resolve
method.
Arguments
route
The route to prefetch.
optional
A route's resolve function is called with two arguments: the match
object for the matched route and an external
value. You can provide filler values for these with the optional
object argument.
match
An object of "match" properties for the resolve
function. The possible properties are name
, params
, location
, and partials
.
external
Any external values passed to the resolve
function.
To access the external
values set on the router when it was created, you can use router.external
.