millermedeiros / crossroads.js

JavaScript Routes
http://millermedeiros.github.com/crossroads.js/
1.44k stars 156 forks source link

destroy function #153

Open mafar opened 7 years ago

mafar commented 7 years ago

Is there a way to completely destroy crossroads instance. I am using it in single page app and it is driving me nuts. After logout and re login .. I want to create instance of router newly but it it keeps adding routes to previous state.

fayway commented 7 years ago

Do you use hasher to handle history state changes? if the answer is yes, during your logout routine, you need to call:

crossroads.removeAllRoutes();

but also:

hasher.changed.removeAll(); hasher.initialized.removeAll();