Skip to content

Commit

Permalink
Update can-route.md
Browse files Browse the repository at this point in the history
  • Loading branch information
chasenlehara committed May 12, 2017
1 parent 0a526aa commit 1d1e244
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions can-route.md
Expand Up @@ -67,26 +67,28 @@ can-route keeps the state of the hash in-sync with the `data` contained within i

## data

Underlying can-route is an observable map: `route.data`. Depending on what type of map your application uses this could be a [can-map], a [can-define/map/map], or maybe even a [can-simple-map].
Underlying `can-route` is an observable map: `route.data`. Depending on what type of map your application uses this could be a [can-map], a [can-define/map/map], or maybe even a [can-simple-map].

Understanding how maps work is essential to understanding can-route.

You can listen to changes in a map with `on(eventName, handler(ev, args...))` and change can-route's properties by modifying `route.data`.

Create an `AppState` and attach it to a stache template like:
Here’s an example using [can-define/map/map DefineMap] to back `can-route`:

```js
const AppState = DefineMap.extend({
var DefineMap = require("can-define/map/map");
var route = require("can-route");

var AppViewModel = DefineMap.extend({
page: "string"
});

let appState = new AppState();
var appState = new AppViewModel();
route.data = appState;

let renderer = stache("....")(appState);
route('{page}', {page: 'home'});
route.ready();
```

Understanding how maps work is essential to understanding `can-route`.

You can listen to changes in a map with `on(eventName, handler(ev, args...))` and change `can-route`’s properties by modifying `route.data`.

### Listening to changes in can-route

Listen to changes in history by [can-event.addEventListener listening] to
Expand Down

0 comments on commit 1d1e244

Please sign in to comment.