meiosis-router
sets up a router that uses Meiosis to produce route-related data to be stored in
the application state.
The Meiosis pattern updates application state which is then used render the view. meiosis-router
complements this concept by also using application state to drive routing.
meiosis-router
provides:
meiosis-router
coordinates between application state and routes:
meiosis-router
can be set up to work one of two modes:
Hash Mode:
#!
, is used as a route prefixhttp://mysite.com/#!/user/42
History Mode:
http://mysite.com/user/42
When setting up meiosis-router
, we provide a mapping that associates route paths to strings that
identify the route.
Route paths are strings that start with a slash, such as '/'
, '/login'
, /user/settings
, and so
on. Route paths can contain one or more route parameters, indicated with a :
prefix, such as
/user/:id
.
meiosis-router
also supports query parameters, which are additional parameters provided at the
end of the URL in the form of ?key1=value1&key2=value2
.
meiosis-router
produces Route
objects of the following shape:
{
value: string,
params: Object,
replace: boolean
}
value
identifies the routeparams
contains the combination of route parameters and query parametersreplace
indicates whether to replace the route in the browser's history instead of adding to it.Using this information, we can perform tasks upon route change, such as loading data, and we can render application views according to the current route.