Closed geraldodev closed 9 years ago
Hi @geraldodev,
Good questions. There isn't a protocol (like HTTP) or any shared abstractions (like Ring) for front-end routing so, unfortunately, most patterns are ad hoc. This is something I'm interested in addressing in the future.
The code you provided seems like a very reasonable way to use Silk. That only thing that immediately stood out is no-match-fn
. You might not need to handle a not found
case since, if you unmatch (generate) all URLs using the same Silk route table you match against, there's no risk of a link not matching. This is unlike server-side routing where users can request arbitrary URLs.
Cheers, Dom
DomKM,
Thanks for the reponse,
"This is unlike server-side routing where users can request arbitrary URLs." The ability of changing the browser's url that the user has leads to the possibility of arbitrary URLs. Does not it ?
I didnt understand "if you unmatch (generate) all URLs using the same Silk route table you match against". Does that imply a different approach handling routes from what I've presented.
Geraldo
If a user changes the browser's URL and requests a new page, that requires server-side routing because the routing occurs on the server, not the browser. When we speak about browser-side routing, the typical pattern is this:
window.history
or window.location.hash
Unless you are doing something very unusual in the browser, like routing based on user provided text, all routing will be initiated by links that you create. Therefore, if you create the links using a bidirectional routing mechanism like Silk, you can know ahead-of-time that all links are valid and therefore a not found
route is unnecessary in the browser. Does that make sense?
DomKM,
Yes, totally, but despite being local the user has access to url and can mess up the address.
The bidirectional routing is a bless. I think the arrive/depart abstraction is good but a url-for alias for depart could be good, since is a common name for the function.
Hi,
First, thnx for Silk. I'm trying to use it. I miss a group where I can post doubts.
I've coded the following in order to use silk at client: Any thoughts on this ? Is this a proper way of using silk ?