Routes can only be assigned in the constructor, which causes problems if context objects are to navigate.
/* If Context wants to be able to navigate here it can't: */
var HomeContext = require('./HomeContext');
var routes = {
'/': HomeContext
};
window.Nav = new Cartier(routes, notFound, contextChanged);
So to solve this we should require the Contexts after Cartier is instantiated, but:
var routes = {
'/': 'UhOh'
};
window.Nav = new Cartier(routes, notFound, contextChanged);
/* HomeContext now can navigate, but route contexts are not contextual data */
var HomeContext = require('./HomeContext');
So ideally:
window.Nav = new Cartier(contextChanged);
var HomeContext = require('./HomeContext');
var routes = {
'/': HomeContext
};
window.Nav.routes(routes);
window.Nav.onNotFound(notFound);
This way, HomeContext has access to the Cartier instance, and routes can contain contextual data.
Routes can only be assigned in the constructor, which causes problems if context objects are to navigate.
So to solve this we should
require
the Contexts after Cartier is instantiated, but:So ideally:
This way, HomeContext has access to the Cartier instance, and routes can contain contextual data.