Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Commit

Permalink
hirearchy
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyWebb committed Jun 14, 2016
1 parent a699749 commit 09923af
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
14 changes: 7 additions & 7 deletions docs/bindings.md
Expand Up @@ -6,13 +6,13 @@ of `ctx.update`. These bindings use that function behind the scenes, so it shoul
surprise that they support the same bubbling behavior, however you can [lock the context](#locking-to-a-context)
if necessary.

## Usage
#### Usage

```html
<div data-bind="path: '/user', state: { user: user }, query: { search: 'foo' }"></div>
```

#### Locking to a Context
##### Locking to a Context

In certain cases, the default route bubbling behavior may not be quite right,
and in those cases you need to nudge the router in the right direction. You can accomplish
Expand All @@ -26,20 +26,20 @@ that with `..`, `./`, `//` following idiomatic path modifiers.
`//` forces top-down traversal rather than bottom-up. For all intents and purposes this can be regarded
as a "absolute path" prefix with respect to the base path.

#### Styling
##### Styling

For convenience, elements with path bindings that match the current route have the `active-path` class
added.

#### Special Notes
##### Special Notes

##### Use Anchors
###### Use Anchors

While the bindings rely on the `click` binding so you can functionally attach them to any element you choose,
if you wish to preserve ctrl+click, context menu (open in new tab/window, etc.), and other native browser UX
you must still use anchor tags. The path binding will set an `href` property for these behaviors to fall back on.

##### Passing Data
###### Passing Data

It may not seem immediately intuitive, but the state binding can be quite handy for passing data around in apps
without a full blown model/collection layer. Imagine the following situation.
Expand Down Expand Up @@ -68,7 +68,7 @@ class ViewModel {
}
```

##### Unit Testing
###### Unit Testing

The bindings expect to find a `$router` object containing the router on the binding context and will throw an
error if it is not found.
Expand Down
14 changes: 7 additions & 7 deletions docs/config.md
Expand Up @@ -2,7 +2,7 @@

These are the options available to pass to the `<ko-component-router></ko-component-router>` component

## routes
#### routes

`routes` is an object where the keys are [express style](https://github.com/pillarjs/path-to-regexp) routes and
values are the array `[...callbacks, 'component-name']` or just `component-name` for shorthand. `...callbacks` are
Expand Down Expand Up @@ -54,14 +54,14 @@ function getComponent(ctx) {
}
```

## base
#### base

The base path your app is running under, if applicable.
e.g., your app is running from a \`/blog\` directory

__This option is only applicable to the top-level router__

## hashbang
#### hashbang

Whether or not to use HTML4 hashbang routing. Defaults to false.

Expand All @@ -75,22 +75,22 @@ with the following one-liner.

__This option is only applicable to the top-level router__

## persistQuery
#### persistQuery

Whether or not to preserve the querystring when navigating between pages. Defaults to false.

Note, when the router is unmounted the queries will be disposed.

## persistState
#### persistState

Whether or not to preserve the querystring when navigating between pages. defaults to false.

Note, when the router is unmounted the states will be disposed.

## inTransition: (el, fromCtx, toCtx) => {}
#### inTransition: (el, fromCtx, toCtx) => {}

Defines a function to run immediately after mounting a component

## outTransition: (el, fromCtx, toCtx[, done]) => {}
#### outTransition: (el, fromCtx, toCtx[, done]) => {}

Defines a function to run immediately before unmounting a component
36 changes: 18 additions & 18 deletions docs/context.md
Expand Up @@ -3,7 +3,7 @@
This is the object passed as the first argument into routed components and available in the
views as `$router`.

## params, read-only
#### params, read-only

Params parsed from the route.

Expand All @@ -23,48 +23,48 @@ class ViewModel {
}
```

## query, read/write
#### query, read/write

#### get(parameterName[, defaultValue, parser])
###### get(parameterName[, defaultValue, parser])

Accessor for read/write querystring observables

#### getAll(asObservable = false)
###### getAll(asObservable = false)

Gets all the query string params for this context

#### setDefaults(params[, parser])
###### setDefaults(params[, parser])

Sets the default values for a batch of params

#### update(params)
###### update(params)

Batch updates query string params

#### clear
###### clear

Resets the params to their default values

## state, read/write
#### state, read/write

Read/write, scoped `history.state` observable

## route, read-only
## path, read-only
## pathname, read-only
## canonicalPath, read-only
## hash, read-only
## isNavigating, read-only
#### route, read-only
#### path, read-only
#### pathname, read-only
#### canonicalPath, read-only
#### hash, read-only
#### isNavigating, read-only

## update([url, state, push = true, query]) => Promise<didUpdate>
#### update([url, state, push = true, query]) => Promise\<didUpdate\>

Updates the context and trigger one update; bubbles up to parent router(s)
if matching route is not found.

Returns `false` if no route is matched, otherwise a promise that resolves the boolean
`didUpdate` is returned.

## addBeforeNavigateCallback([done]) => Promise<shouldNavigate = true> | done([shouldNavigate = true])
#### addBeforeNavigateCallback([done]) => Promise\<shouldNavigate = true\> | done([shouldNavigate = true])

Adds function to be called before navigating away from the current page. To perform async
actions before unmounting, you may use the optional done callback or return a promise.
Expand All @@ -74,10 +74,10 @@ with the first argument `false`, navigation will be prevented.

You can use this function to confirm navigation away, show unsaved change warnings, perform async cleanup, etc.

## $parent
#### $parent

Parent router ctx accessor

## $child
#### $child

Child router ctx accessor

0 comments on commit 09923af

Please sign in to comment.