Skip to content
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

switch svg and button default to static #584

Merged
merged 6 commits into from
Sep 20, 2024

Conversation

jrmoulton
Copy link
Collaborator

No description provided.

@jrmoulton
Copy link
Collaborator Author

I think zoxc mentioned this a while ago and now I pretty strongly agree with it

@dzhou121
Copy link
Contributor

dzhou121 commented Sep 20, 2024

would something like this would be better

pub fn svg(svg_str: impl Into<String> + 'static) -> Svg {
    let id = ViewId::new();
    id.update_state(svg_str);
    Svg {
        id,
        svg_tree: None,
        svg_hash: None,
    }
    .class(SvgClass)
}

impl Svg {
    pub fn update(self, svg_str: impl Fn() -> String + 'static) -> Self {
        let id = self.id;
        create_effect(move |_| {
            let new_svg_str = svg_str();
            id.update_state(new_svg_str);
        });
        self
    }
}

so that we don't have svg dyn_svg

Not sure about the method name update though, could be value?

@jrmoulton
Copy link
Collaborator Author

ah yeah that seems good. I think update makes sense.

@jrmoulton
Copy link
Collaborator Author

used update_svg as the method to avoid confusing with View update method

@dzhou121
Copy link
Contributor

maybe consider using value so that we can use it for all views that needed it, e.g. label etc

@dzhou121
Copy link
Contributor

or update_value?

@jrmoulton
Copy link
Collaborator Author

👍

@dzhou121 dzhou121 merged commit 4b98f8c into lapce:main Sep 20, 2024
7 checks passed
@jrmoulton jrmoulton deleted the static-constructors branch September 20, 2024 09:36
jrmoulton added a commit to jrmoulton/floem that referenced this pull request Sep 26, 2024
* switch svg and button default to static

* fix linux/clippy

* fix tests

* button view as child, svg update method

* fix linux

* rename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants