canjs / can-route

Observable front-end application routing for CanJS.
https://canjs.com/doc/can-route.html
MIT License
10 stars 4 forks source link

Teach people to setup route data on observable object within their app state #170

Open justinbmeyer opened 6 years ago

justinbmeyer commented 6 years ago

From: https://github.com/canjs/can-route/issues/160

I think we should change our docs (maybe bitballs) to show an app setup more like:

import {route, DefineMap} from "can";

AppVM = DefineMap.extend("AppVM", {
    routeData: { 
     // Perhaps in 5.0, we should make this the default route data?
     Default: DefineMap.extend({seal: false},{}) 
    },
    init: function(){
      route.data = this.routeData;
      route.start();
    },
    ...
  })