diff --git a/can-route.md b/can-route.md index 577984d..d8a141e 100644 --- a/can-route.md +++ b/can-route.md @@ -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