-
Notifications
You must be signed in to change notification settings - Fork 25
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
Router and browser reload #31
Comments
Unfortunately, I haven't added support for fragment-based history at all. It's something I've been thinking about for a while, but I haven't gotten around to it. TBH, since nobody had asked, I wasn't sure it was a problem. :-) I can work on it a bit this weekend unless you'd like to send a PR before then. The thing is, we have to somehow get Honestly, the router is the thing I'm least comfortable with code-wise. Once the tests went green while I was writing it, I basically committed it and backed away slowly. :-) I've done very little with it since then except to simplify a few things. |
I think the reason we had problems with this is that we are running in electron (atom-shell) as a single-page application so we never hit a server on reload. I guess it's not a problem if you can map everything below a base url to the same server-side generator. Making For Feel free to close this since it was more of a question that an issue :) |
Ahhh, cool. I wonder if we should just add a fragment-based router or make the history object inside the router (currently using The automatic switching between fragment and pushState is something I've mulled over in my head a lot but haven't really codified yet because I haven't been sure it'd be worth it. I'd been mostly thinking that it was just IE < 10 that would need to worry about that. Not being able to use it in Electron wasn't something I'd thought of at all. Does I'm totally gonna keep this issue open until we can solve this. It may just be a question, but if people want to build Electron apps, I think this is all valid conversation to have. :-) |
Actually most things worked, but we ran into some issues after using navigate_to "/some/route". After that we could not load images anymore and it wasn't obvious (to us) why. After reading through the code and finding pushState things became clear :) (the leading / caused the documentURI to be cleared) I think my major issue with the router is that it is an object instance on my app, but uses a global for state. That can lead to all kinds of weird behaviour that is hard to debug. Making navigate_to static at least makes that behaviour explicit. A better approach for our application would be that Link uses the current rendering applications router instead of using href. (Or if Link is intended as a 'fixed' , introduce another component that works that way). The router would handle whatever needs to be done, be it pushState or just updating the current app model. The important part is that it is very explicit where you would handle that logic. As a side note, when i implemented something similar in React, I passed down a |
I think |
@johnsusi Do you have a link to a minimal/hello-world Clearwater+Electron app I could use to get started on trying to ensure the two work well together? :-) In addition to wanting to make sure routing works well for it, since I've removed the dependency on |
@jgaskins Sorry for the late reply. I must have missed the notification. I put up a simple project at https://github.com/johnsusi/electron-clearwater There are some issues with it, for instance virtual-dom.js does not appear to be loading correctly but it's a start. I intent to add scripts for packaging native apps. |
Ah, yeah, I remember when I played with getting Electron to work with Clearwater (after you opened this issue), it seemed to have 2 JS environments: v8 running inside the app window and Node running on the back end. I have no idea if this is accurate, I'm going off of stale memories. :-) I remember I had to get the Clearwater code running in the app window side, so basically I was loading its file as a I'm really glad you're experimenting with this. Let me know if there's anything I can help with! :-) |
I had some issues when trying to reload a page after using Router::navigate_to or when clicking a Link element.
To solve this I created a custom Router like this
So now the router keeps track of the view using fragments and location[:pathname] stays fixed.
Is there some 'official' way of doing this?
The text was updated successfully, but these errors were encountered: