-
-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: added in a new fallback route feature. #731
WIP: added in a new fallback route feature. #731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool. So stoked for this. Can't wait to hear how it goes in your app 🤞
…er. things are a little wonky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Once you’ve tested in your app and it works, could you revert the original changes and ping me? Then I’ll merge this in 🎉
wtf? apparently I don't know how to git this morning. 😕 |
@paulcsmith ok those router changes are removed from this PR now. Do you want me to send another PR to re-implement those with the reset? Or just open an issue to handle later? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect 👍
I think we can leave the Router as-is now that we don't need to reset it anymore. The INSTANCE
constant really is a constant again so is probably ok. What do you think?
Oh and did you try this out on your app and can confirm it works? |
I like leaving it as a constant; however, I think maybe the specs need to be a bit more robust. The fact that each spec instance carries over information from a previous spec isn't good. But I think that can be a low priority situation since it doesn't really affect an app (that I can think of) |
@jwoertink Yeah that makes sense. I think an issue to handle it later would be good. Making them more robust would be great. Also what do you think about catch-all v. fallback? Example |
It does work on my app locally. This app isn't in production just yet, but it's working as intended. There's a weird issue now with the fact that lucky no longer throws a 404 on GET routes when the fallback is added. Though, I spoke with a few different react devs and they say that's sort of common. I guess with rails it's pretty common to use a glob route, and have the SPA handle the routing... And on that note, the SPA will handle non-existent routes (provided you handle that yourself), it's just lucky returns a 200 as opposed to 404. I think that's ok though, just maybe needs to be documented? |
I do like |
Yeah let’s just stick with fallback for now :) And that is one of the bummers about the SPA life. Though I’d suggest something like this in the FallbackAction most of the time: fallback do
if json?
raise Lucky::RouteNotFoundError.new
else
# do your thing
end
end That way JSON responses still get a 404. That can be documented in the guides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. I’ll go ahead and merge but if you try it and find any issues, I’d be happy to open review a new PR
Fixes #728
I labeled this as WIP since I'm sure there will be a few comments on this. Plus I'm going to implement this in to an app to feel it out a bit and see what might be missing.
This adds in the feature of a fallback route using
This also removes the
Lucky::Router::INSTANCE
constant to a new private class property due to an issue with the specs where each spec would carry over the instance variables. Doing it this way allows us to reset that internally. It should be noted that thisreset!
is not intended to be a public API, and anyone else reading the code that uses it should expect nothing less than an explosion 😆