Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Justin Starry
    @jstarry
    Yew works by taking the dom tree structure you want, and comparing (diffing) it with what is currently shown in the browser. It will then use browser apis to use minimal updates to achieve the new structure

    Maybe someone with more expertise can chime in here, but I think Yew is written in a way that assumes that there will always be a post-mount lifecycle to each element, i.e. to handle prop changes or state updates, which wouldn't necessarily need to be true in SSR, so there might be some relaxation of the necessity to implement VDiff that could be achieved through a refactor.

    @philip-peterson yeah I think we might want to disable VDiff for SSR. Not sure what that would look like right now though

    Justin Starry
    @jstarry

    @jstarry Thanks for the advice. I'll try to implement all of them because I'm actually just trying Yew out right now. Agents are quite cool but It feels like I'll have to implement everything twice.

    @JonasZ95 awesome, be sure to report back your findings on that issue. It hasn't been too active lately

    John W.
    @TrustTheRust
    Hi there! i'm experiencing a breaking change switching from .11 to .12 that isn't listed;
    The RouteAgent::Bridge(callback) is throwing an error,
    error[E0599]: no function or associated item named `bridge` found for type `yew_router::agent::RouteAgent<_>` in the current scope
    
    |
    74 |         let router = RouteAgent::bridge(link.callback(|_| Message::Ignore));
    |                                  ^^^^^^ function or associated item not found in `yew_router::agent::RouteAgent<_>`
    |
    = note: the method `bridge` exists but the following trait bounds were not satisfied:
    `&mut yew_router::agent::RouteAgent<_> : yew::agent::Bridged`
    `&yew_router::agent::RouteAgent<_> : yew::agent::Bridged`
    `yew_router::agent::RouteAgent<_> : yew::agent::Bridged`
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
    `use yew::agent::Bridged;`
    use yew::agent::Bridge;
    use yew_router::agent::RouteAgent;
    
    
    pub struct Model {
       router: Box<dyn Bridge<RouteAgent>>
    }
    
    let router = RouteAgent::bridge(link.callback(|_| Message::Ignore));
    Kelly Thomas Kline
    @kellytk
    How can I cause a user to be prompted with a file download dialog in response to user interaction? When a user performs some action, such as clicking a button, the app will calculate the URL of a file and somehow cause the download dialog to appear for the user
    adante
    @adante_twitter
    @jstarry i would put money on PEBKAC but the repo is at https://github.com/adante111/yew-app-to-wasm-attempt. wasm-pack build seems to run ok, but when i try to run rollup i get this https://pastebin.com/zfPVY6ku . again to stress I am new to rust/yew/wasm/webdev/arguably programming in general :P so fairly blindly doing stuff without any inherent understanding, so apologies in advance if it's something painfully obvious
    Stefan Junker
    @steveeJ
    @jstarry awesome, I think I understand, thanks! let me verify that by asking: with VComp::generate_ssr you mean a new variant of vcomp.rs#l15?
    Justin Starry
    @jstarry
    @steveeJ yeah pretty much, I was implying that something like a generate_ssr function could be added to the Unmounted
    Justin Starry
    @jstarry

    @adante_twitter I had to remove a few things to get your project to build.

    First, remove your main.rs file. It isn't required for a wasm-pack built projects because wasm-pack builds your application as a library (lib). It's not a binary so there's no main entrypoint.
    Second, remove the fn main() function in your lib.rs

    I was able to build and run your project after that with these commands:

    wasm-pack build --target web
    rollup ./main.js --format iife --file ./pkg/bundle.js
    python3 -m http.server 8080
    Justin Starry
    @jstarry

    How can I cause a user to be prompted with a file download dialog in response to user interaction? When a user performs some action, such as clicking a button, the app will calculate the URL of a file and somehow cause the download dialog to appear for the user

    @kellytk afaict you have to use <a> tags to download files https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

    Justin Starry
    @jstarry
    @TrustTheRust I'm pretty confused as to what would have caused a breaking change like that in the latest release. What version of yew-router are you using?
    In yew v0.11 you don't need to add use yew::agent::Bridged;?
    Kelly Thomas Kline
    @kellytk
    It's not possible to programmatically initiate a download? That seems odd
    Justin Starry
    @jstarry
    It's not possible from what I can tell. Have you ever had your browser download something when you didn't click something?
    Kelly Thomas Kline
    @kellytk
    No, however I've been able to click buttons and not only a elements
    Justin Starry
    @jstarry
    you can wrap buttons in <a>
    Kelly Thomas Kline
    @kellytk
    Thank you
    Justin Starry
    @jstarry
    :thumbsup:
    adante
    @adante_twitter
    @jstarry thanks again! as it turns out it seems to workout needing to change anything with just specifying the --target webdirective (which I wasn't aware of)
    Matthew Pocock
    @drdozer
    I'm having a bit of trouble getting yew-router to behave :(
    firstly, the really odd thing is that match over the route enum isn't being checked for being complete
    secondly, the url is changing, but the content that is supposed to switch on route isn't changing
    I've probably done something very silly
    Matthew Pocock
    @drdozer
    OK, it's just returning the first widget in the router match switch statement regardless
    something here is very borked ... Index => html! { <div> { format!("Rendering for route {:?}", switch)} </div> }, When I navigate to /login this is rendering Rendering for route Login but within the Index handler!
    Jeremy Scatigna
    @jeremyscatigna
    Hi there ! I'm new here, I'm a frontend engineer learning Rust and what a better way for me to learn than a project like yew :) Would be happy to help and be guided in my contributions ! If someone could point me to an issue I could start with it would be more than welcome :)
    Matthew Pocock
    @drdozer
    fyi I fixed my matcher - I hadn't imported Index from the router enum, so it was just binding a pattern match variable named Index -- I think this may be the first time since starting rust that I've missed scala's case-sensitive rules
    Justin Starry
    @jstarry
    Hey! Welcome @jeremyscatigna ! Check out the issues here if you want to contribute! https://github.com/yewstack/yew/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22
    Feel free to comment if you need any clarification or direction
    @drdozer oh bummer! Glad you figured it out
    Matthew Pocock
    @drdozer
    @jstarry cheers! I went to the gym for an hour, and as soon as I sat down at the ide again it was obvious
    Matthew Pocock
    @drdozer
    I'm getting a lot of "recursion limit exceeded" errors
    Matthew Pocock
    @drdozer
    I've set ![recursion_limit="4096"] but that hasn't helped
    so I guess this is coming from the html! macro, because slimming down that gets rid of the error
    mm, I think it is a lot worse if there is an error in the content of the html! macro so perhaps it is in the error reporting process?
    yes - when I fixed the error, it ran without the recursion problem. This is a bit of a pain.
    Matthew Pocock
    @drdozer
    so I have a login form - it authenticates the user using a service, and should then notify the containing component presumably by calling its on_loggedin property
    I'm not quite sure how to do this though
    the derive Properties is complaining that the callback doesn't have a Default instance, but I don't want to wrap the callback in an Option, as I want the callback to be forced to be supplied
    Matthew Pocock
    @drdozer
    a, I found #[props(required)]
    Matthew Pocock
    @drdozer
    I've kind of hit a brick wall with Router;:render - it requires an Fn but within it some of the pages rendered for the routes need to be handed state from &self in the form of callbacks, and I can't work out how to make that work
    let on_login = self.on_login.clone();
    html! {
    <Router<AppRoute> render = Router::render(|switch: AppRoute| { match switch {
      AppRoute::Login => html! { <login_form::LoginForm on_login=on_login /> },
    the on_login inside render captures the definition outside, so the render closure is an FnOnce, not an Fn
    I can't see how to juggle this to avoid the problem :(
    Matthew Pocock
    @drdozer
    OK - if you use move in the render closure, and also clone on_login within it, it all works
    Justin Starry
    @jstarry

    yes - when I fixed the error, it ran without the recursion problem. This is a bit of a pain.

    @drdozer could you please share what your error was? The goal is to have the html! macro always give a nice error message. Would love to have a test case for what you were seeing

    Justin Starry
    @jstarry
    @kellytk the blog post you linked is still creating an anchor element and setting a data uri on it. It needs to be started from a user click, but then dynamically creates the anchor element before calling click on it. You can do all of that with stdweb or web-sys depending on which you are using
    Kelly Thomas Kline
    @kellytk
    Thanks