Skip to content

Deleting routes once created #55

Open
cdrubin opened this Issue Oct 4, 2012 · 5 comments

4 participants

@cdrubin
cdrubin commented Oct 4, 2012

Is there a way to reset or remove all routes that have been registered with Davis? Fanks!

  • Daniel
@olivernn
Owner
olivernn commented Oct 5, 2012

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.

@cdrubin
cdrubin commented Oct 5, 2012

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.

  • Daniel
@jona10
jona10 commented Jan 23, 2013

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

Edit

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.

@olivernn
Owner

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.

@cnizzdotcom

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.