0.0.6
Represents some sort of API param that is embedded in a URL
(function)
a function that takes a url and returns the api param
(string?)
pretty name of this param to display
(function?)
is the value valid
const ParamSearch = new QueryParam(
(v) => (`where name = '${v}'`),
'Search',
(v) => /(\D+)/.test(v))
const ParamID = new QueryParam((v) => (`where id = ${v}`), null, null)
An enumerated QueryParam that can only have one value
Extends QueryParam
(string)
the exact value of the param
(function)
a function that takes a url and returns the api param
(string?)
pretty name of this param to display
const ParamSortName = new QueryEnumParam(
'abc',
() => ('order by name'),
'by Name', )
const ParamSortPop = new QueryEnumParam(
'pop',
() => ('order by count desc'),
'by Popularity')
Base object to inherit from
(string)
the instance href of the location
(object
= {}
)
Name | Description |
---|---|
config.debug bool
(default true )
|
extra debug info |
config.log func
(default console.log )
|
debug logging func |
export class TestLocation extends Location {
static route = '/test/:id(\\d+)/'; // eslint-disable-line no-useless-escape
static params = {
'o': [
ParamSortName,
ParamSortPop,
],
'q': ParamSearch,
'id': ParamID,
}
}
(string) @see route-parser https://github.com/rcs/route-parser Should be set in derived class.
(object) valid paramaters in search i.e. QueryParams. Should be set in child class.
(object) will add default values to url search if not present
(array) will always be added to matched params