Comments (14)
Related: Attempting to simplify routing syntax further using Regex. (Eg set up a regex map once to match all patterns, and just have the routing events trigger pushState etc.)
from seed.
My understanding is that # routing was a workaround used before pushState was released.
Mozilla's listed advantages of pushState:
"
-
The new URL can be any URL in the same origin as the current URL. In contrast, setting window.location keeps you at the same document only if you modify only the hash.
-
You don't have to change the URL if you don't want to. In contrast, setting window.location = "#foo"; creates a new history entry only if the current hash isn't #foo.
-
You can associate arbitrary data with your new history entry. With the hash-based approach, you need to encode all of the relevant data into a short string.
-
If title is subsequently used by browsers, this data can be utilized (independent of, say, the hash).
"
from seed.
My understanding is that # routing was a workaround used before pushState was released.
but if I'd copy a link like https://example.com/single-page/home and share it with someone else I'd expect that the foreign browser sends a real HTTP request to the server.
from seed.
...e.g. try to open https://seed-rs.org/guide/12 what do you see?
from seed.
I think that's supposed to be handled by the server; I'm not sure how to do it on the hosting I'm using. Ie what's supposed to happen is the server routes all sub-urls to the main one. (And then the framework reads the url and routes appropriately internally)
from seed.
I think that's supposed to be handled by the server;
to be honest, I don't want special frontend logic in my server, I just wanna drop my app on a standard server. But that's only my opinion ;-)
from seed.
Would love to hear what someone more experienced than I with frontend routing thinks
And if anyone knows how to configure Netlify for this to fix the Seed homepage landing-page routing, I'm all ears.
from seed.
Yeah you typically just get the server to serve up index.html
on any request, then make the framework trigger and update immediately upon load. For example here is there relevant crates.io
code (crates.io is a single-page ember app).
I would recommend against using #
for anything other than anchor tags. Routing should be done as 'natively' as possible so back, forward and linking work the same as a static site would.
from seed.
Yeah you typically just get the server to serve up
index.html
on any request, then make the framework trigger and update immediately upon load.
I see
For example here is there relevant
crates.io
code (crates.io is a single-page ember app).
yes, here it works as expected :)
As long as I can reproduce the route I'm totally fine with it :)
I would recommend against using
#
for anything other than anchor tags. Routing should be done as 'natively' as possible so back, forward and linking work the same as a static site would.
Yes, in that way I can agree :)
So this issue is more about making the framework trigger routing and updating immediately upon load.
from seed.
To elaborate a little - since Seed is based on Elm - in production Elm, the main
function is Browser.application, which as you can see takes as the init
argument a callback that returns ( model, Cmd msg )
. This init
callback is called once the app has loaded, and inside that function you would typically set up the model, then parse the URL as typed into the address bar and return some kind of routing message which is then processed as part of the normal event loop.
This seems like a nice way to do it. The framework need not trigger routing itself, but merely provide the URL to some callback.
from seed.
@jesskfullwood I think creating an init argument like that's elegant. In addition to initial routing, it would remove the need to put side-effect (eg loading data from a server) setup code in a did_mount, which feels awkward.
from seed.
Is initial routing not working for y'all as-is? routing::initial gets called on app load, which checks the path against the routes
HashMap. API-design-wise, I don't think it's necessary to explicitly specify the initial route, since it should be included in routes
.
For me, it works for top-level paths, but fails more than one level down (Or is that my hosting and dev server?) The error I'm getting's difficult to diagnose: SyntaxError: expected expression, got '<'
, where the web server tries to load the html file as JS.
from seed.
I redid the routing module to use a cleaner, more flexible API (committed; not released on crates), and I'm still not sure if this is a bug in seed, or a problem with server config. In relation to @flosse 's original question, routing now supports location hash
and search
, although they appear to be bugged atm.
from seed.
Fixed, by @jesskfullwood 's homepage PR reffed above
from seed.
Related Issues (20)
- error[E0425]: cannot find function `wheel_ev` in this scope HOT 1
- 1. Create a new issue in the Seed repo with the name and copy-paste this checklist into it (also add blockers and additional tasks, if exist).
- Maintenance & Future of Seed HOT 8
- v0.9.1: browser::json::Error is inaccessible
- Deserializing large numbers fail HOT 11
- Websocket example does not work HOT 2
- how to integrate with another wasm ?
- Websocket API changed from 0.8 to 0.9 HOT 5
- DOM node is not attached to ElRef under some conditions HOT 6
- Does not build with wasm-bindgen 0.2.81 HOT 3
- Closures need types HOT 3
- Release v0.9.2 HOT 3
- Seed 0.8 accepting the newest wasm-bindgen HOT 3
- [0.8.x] WebSocket and too early dropped closure HOT 1
- support `beforeinput` events HOT 1
- Seed doesn't compile with `default-features = false` HOT 2
- checkbox not working HOT 2
- Release v0.10.0 HOT 3
- Cannot use subs (subs::UrlChanged) HOT 2
- Error: unresolved import in wasm_bindgen_initialize HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seed.