Can we initialize a empty router
satyasuman opened this issue · comments
Satya Suman Saridae commented
Hi is it possible to initialize an empty router and then add routes to it?
Andrea Zicchetti commented
Hi,
yes, you can setup an empty router, then add your routes at a later time.
Just invoke the add() method of the router instance:
myrouter.add({
"#something": "bsHandler",
"#otherone": { events: "s,h", handler: "bsHandler2" }
}, handlerObj);
The array syntax is also supported (and preferred):
myrouter.add([
{ "#something": "handler" },
{ "#otherone": { events: "s,h", handler: "handler2" } }
], handlerObj);
Cheers,
Andrea