Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Ideas #6

Open
guilhermeaiolfi opened this issue Mar 22, 2015 · 7 comments
Open

Ideas #6

guilhermeaiolfi opened this issue Mar 22, 2015 · 7 comments

Comments

@guilhermeaiolfi
Copy link

Sometime ago I started working in a router that could do what you're trying to do with roadtrip. It started as an ember project and it was so difficult to replace the ember router (eventually I did succeed) that I started looking how that would work for other libraries and that's the main reason I'm using ractive in my projects now.

For my router I created a transition object that would hold all the info about the transition and its state. So you could get the next route, previous route, first, last, etc. And do stuff to them like rewind, reset, next.

Since you have control over the transition object, it can do async (for example, load code in one route and resume the transition when the code finish loading) or some other crazy stuff. You can see it here: https://github.com/guilhermeaiolfi/ember-craziness/blob/master/lib/routing/router.js

The whole thing is just ~300 LOC. To be honest, it is just an abstraction on top of https://github.com/tildeio/route-recognizer. But it worked.

Maybe it won't help you. Maybe it will. I thought I would mention because I'm very interested in something like that. I've tried all routers and was very disappointed.

@Rich-Harris
Copy link
Owner

@guilhermeaiolfi Thanks - I won't pretend to understand all of it from an initial reading of the code, but I'm relieved to know that other people have had similar problems. Makes me feel like I'm not crazy. I opted to focus on the simple a <-> b transition rather than maintaining a full state history because it seemed like an unsolved problem that was small enough to tackle (window.history is my undo stack!) but it may yet turn out we need something beefier. For now my plan is to keep things as simple as possible and only add features when it becomes problematic to not have them, because frankly:

enhanced-14836-1414320930-8

@guilhermeaiolfi
Copy link
Author

This project has some nice ideas: https://github.com/erikringsmuth/app-router

@arxpoetica
Copy link

"Maybe I've fundamentally misunderstood the problem. If someone can point me to a decent router that solves these issues, let me know so that I can stop working on this one."

Did you change your mind? Find something better? Or is this still something you're using?

@Rich-Harris
Copy link
Owner

Still using it. All the other routers these days seem to be view-layer-specific. I'd rather have something that's less coupled to the rest of my stack and lets me be imperative when I want to be imperative. There's certainly more sophisticated options out there but I've never had whatever problems they're trying to solve

@arxpoetica
Copy link

Word. I'm going to start using it. Maybe I'll become a contributor. ;)

@cmalven
Copy link

cmalven commented Nov 27, 2017

Just started using roadtrip this week after I saw it recommended by the Page.js maintainers. I was planning on building something similar and custom for this project, but roadtrip has handled my use-case so closely and so smoothly that it is almost spooky.

Exactly what I need for this project and so many projects in the past (and almost certainly the future).

Fantastic work @Rich-Harris

@Rich-Harris
Copy link
Owner

Thanks! That's great to hear

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants