Open cdrubin opened 12 years ago
Currently there is no way of doing this, the list of application routes is not currently exposed.
Why do you need to remove all the routes? Perhaps there is a better way to achieve what you want, if not I can look into exposing the the routes list.
Hey there olivernn, and thanks for the interesting library.
My application bases its URL navigation on resources that can be created (routes added) or deleted (routes removed). I would like to either be able to selectively remove a route on delete or if need be reset them all and re-create only those that are still valid. What do you suggest? Thanks.
Hi Oliver, Sorry to bump an old thread, but I'm in the same situation as Daniel. I'm building a plugin like single page application where plugins can be added or removed at any time. I tried stopping the router, overriding my router instance with a new App instance, re-registering and starting. When I do that, runRoute fires as many times more as I "restarted" the App. I do feel that this workaround would be a little hacky and that it would be easier on the general load to "unregister" a route instead of bringing down the whole machine and back up again.
Do you have any other suggestion?
Thanks in advance, Jonathan
The multiple call of events problem stems from internal events not being unbound when the app stops. Since the callbacks are statically stored, re-starting a stopped application will only add the same handlers another time.
I wrote a fix so I can use this workaround and will contribute it back when I'll be home (company blocking external git servers). I still wish to see a "remove route" feature in future developments.
This is a feature that I will be adding in the next major release of the libary. I hope to find some time to work on it soon (lots of other stuff going on currently!).
@jona10 - thanks for the pull request, I'll have a look and get this fixed so the workaround discussed here works better.
On this same note, why is there no way to see what routes are currently set? Is this trivial to expose? If so, please provide a method to get this data.
Is there a way to reset or remove all routes that have been registered with Davis? Fanks!