spine / spine

Lightweight MVC library for building JavaScript applications

Home Page:http://spine.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

routes

dmitkataev opened this issue · comments

Hi,
i don't know for sure if it is an issue at all - I found that there is a way to add routes to Spine.Route but there is no ability to remove them. For example if i want to do something like Spine.Stack and add routes to edit/show methods inside its constructor, as it's describe in documentation, i'm not able to do release this stack controller correctly - routes is still binded. When an instance of that Stack controller is created again, same routes are added again. It cause incorrect work of @Navigate.
Is it possible to manage it somehow?

This is currently a limitation of Spine.Route. I'm (slowly) working on a refactor of Spine's routing to allow discrete router instances and the ability to unbind routes.

Planning to publish a router-refactor branch for community feedback once I have time to resolve conflicts introduced in the latest dev code. Stay tuned!

Thanks, Adam! I'll wait for updates.

@dmitkataev removing routes hasn't been a requirement for us yet, but I can see where it might be for some. There should be a way to do it manually, just by dealing directly with the route object, but also it shouldn't be terribly hard to build something into spine if it is a feature that some others also want.

@adambiggs Eager to see what you have as well.

Just published the router-refactor branch. Would love to get some feedback!

from what I see so far it looks very promising. Am I right that there is no obvious breaking changes to the way it worked before?

I tried hard to minimize breaking changes. The previous class methods should still work as before, but they forward to Route.router - the default router instance.

I think the biggest API difference is that "change" events now pass an array of matching routes (Path instances), instead of a single route like before.

Also, the recently added "before" event will fire once for each matching route... Not sure if we want that to happen.

I'm trying to figure out how to make use of the before event. Is that something that will be triggered on the controller? How would I bind to it? Will that happen before activate() is called?

I'm thinking this will be useful for controllers that require login.

this had been mostly fixed for a while, but especially with last couple minor releases I think this should no longer be an issue.