Comments (9)
Yeah, this library will not work in non-stdweb compatible environments.
While you are welcome to maintain a fork, I don't currently want to take on the additional responsibility of making sure this works outside browsers as this library was only developed for being used within the context of a yew application (or possibly another wasm frontend framework).
To remove Stdweb currently means that the Route
struct wouldn't be representable any more (or would otherwise break compatibility with its use in the frontend). That will hopefully change after #185 is implemented and stdweb trait bounds (JsSerialize
) can be removed.
I would like to point you towards Rocket and Warp, which while not using a enum to describe their routes, do use macros to extract data from request paths.
I don't want to say no here, but implementing server-side support isn't a goal of this project, and other, dedicated backend frameworks have solved this problem better for use in a server-side context. I think it might be supported eventually (by making the minimal
feature even more minimal), but it isn't on any near-term roadmap.
from yew_router.
I completely understand. I forked it myself and it's just fine. My recommendation is to consider this on the next iteration or refactorization which may or may never happen. Until then I'm very happy using my own fork of yew_router. Thanks!
from yew_router.
I've gone ahead and made the service
module a feature. This means using the library without any default features should allow you to use this library in non-web environments.
Can you add the following as a dependency for your project and let me know if it resolves your problem?
yew-router = {git = "https://github.com/yewstack/yew_router", branch = "feature-gate_service", default-features=false }
I still don't want to constrain myself to guaranteeing that this library will not require yew or stdweb when using it without any features, but I will do my best to avoid that scenario.
from yew_router.
Could you include this commit (without removing From<Option>
)? I think it's equivalent and I need it to deserialize path elements and I think it's a good feature to include with less code.
from yew_router.
If I recall correctly, the reason I broke the implementation out into a macro was to allow Switch to be implemented on Option
, because coherence rules said that if std
added a FromStr
for Option
, then there could be a set of overlapping implementations.
I absolutely would like to get something like that working, but I think it would require sacrificing that support for Option
. I'll give it a shot and get back to you.
from yew_router.
Try out the latest commit on that branch. I had to remove the Switch implementation forOption
, replacing it with a Permissive
wrapper around Option instead and Route::<()>::from("string")
no longer works, and you must use Route::new_no_state("string")
instead.
Versus what your commit contained:
The API will always use a Route
because the frontend must deal with the possibility of storing state within the browser's history. But the Option<STATE>
(Option<T>
) should be going away in the near future, being replaced with just STATE
, but the route String
is probably going to remain a String
, although maybe a Cow<str>
might be used instead.
from yew_router.
I intend to momentarily merge #204
Try out the latest master
instead get access to the changes embedded in there.
from yew_router.
It does work, awesome. I only miss one thing, in my fork I could do:
match App::from_path(req.uri().path()) {}
Now I am using:
let (route, _) = App::from_route_part::<()>(req.uri().path().into(), None);
match route {}
Maybe even this would be possible:
match req.uri().path().into() {}
Using impl From<&str> for Route<()>
and impl<S, T: Into<Route<S>> From<T> for SwitchImpl
.
I really appreciate your work and now I certainly will not have to maintain my own fork and .into()
is just something you could think about and if I can help let me know.
Thanks again!
from yew_router.
There should be a Route::new_no_state
or Route::new_default_state
to create a Route<()>
.
Using this you could make it a little more terse with something like:
let route = App::switch(Route::new_default_state(req.uri().path().into()));
Additionally, I think its kinda dumb that you still have to reallocate the &str into a String in order to parse it, but switching to another design would break core functionality of this lib. If your framework takes off, you may want to re-investigate forking to avoid that cost, but for now I don't think its worth it
If you submit a PR to add a blanket impl that doesn't cause any more API breakages, I'd happily merge it, but for now I think I'm done working on this problem-space.
from yew_router.
Related Issues (20)
- Fragment route not working HOT 15
- Switch derive macro doesn't handle type parameters
- Allow paths and queries to exist after a fragment
- Route state field should be just T HOT 2
- Only allow route: T: Switch in Props to Anchor and Button components.
- Change type parameter for state value from T to STATE
- js-sys/web-sys parallel implementation HOT 1
- minimal example fails to build HOT 7
- v0.8.0 fails to build with wasm-pack HOT 10
- RouterAnchor does not generate `href` for <a>
- Add support for web-sys HOT 1
- Code generated by `Switch` derive macro depends on evaluation order of tuple constructor arguments HOT 4
- cargo clippy failed for web-sys feature HOT 6
- Lost history when refresh page(web_sys) HOT 4
- [docs.rs] docs.rs failed to build yew-router-0.10.0
- Child page not properly updating when path updates HOT 2
- Adding yew-router to cargo.toml breaks build HOT 2
- page not found after refresh browser HOT 2
- This repo is duplicative/confusing HOT 2
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 yew_router.