-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow specifying worker script location as absolute or relative to current path #2056
Comments
Because the computation is actually really fast and due to yewstack/yew#2056, it is easier to simply not use threads to handle this computation.
Hi 👋
Agreed, I think the use case you stated above shows perfectly why this would be the case. I'd like to see both approaches available for users.
I'm curious whether you had a possible solution in mind? Housekeeping:
As you've stated the change was purposeful so If you think this is wrong just let me know 👍. |
Thanks, I agree with all you write. Regarding a proposed solution, how about adding the following method and default implementation to the /// Declares the behavior of the agent.
pub trait Agent: Sized + 'static {
// ...
fn resource_path_is_relative() -> bool {
false
}
} This would allow setting an relative path if desired in the implementation of the trait, but would keep the current behavior as default. I haven't implemented this but it seems like it should work. |
I'm happy with this approach, though I'd prefer if the name of the function was more similar to Marking this as feature accepted so feel to submit a PR with this change 🎉Any issues just ping me either here or in the PR :) |
as discussed here yewstack#2056
* allow web worker resource to be relative fixes #2056 * make backwards compatible with rust < 1.52 * fix clippy warning * Apply suggestions from code review Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk> * do not reimplement stdlib function * fixup previous * improve docstring Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
Problem
In older yew (0.15 and earlier), worker scripts were specified with a name relative to the main script. Now, I must anticipate the final URL of my scripts and specify any leading path components in
Agent::name_of_resource()
because this is now treated as relative to the origin and thus absolute. However, it would be useful to allow the relative behavior again as this would allow yew apps (with workers) to be dropped into a directory not at the root of a website,One could potentially call this a regression but the behavior was purposefully changed in #1208 to fix #1175. In #1175, @domdir made two proposals:
href should be replaced with either: "page origin" or "page origin + pathname"
. As noted (While page origin + pathname is closer to the way it behaves currently, I think the correct solution, however, is to only use the page origin
), the preference was for "page origin" only and that was indeed the result of #1208, but I think "page origin + pathname" has a valid usecase.Expected behavior
I think it should be possible for an app to opt-in to the old behavior or specifying the web worker name relative to the app.
Environment:
Questionnaire
The text was updated successfully, but these errors were encountered: