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

Support the use of Store #308

Closed
LukaOber opened this issue Nov 18, 2024 · 1 comment · Fixed by #320
Closed

Support the use of Store #308

LukaOber opened this issue Nov 18, 2024 · 1 comment · Fixed by #320
Labels
enhancement New feature or request

Comments

@LukaOber
Copy link

I would like to use Store in thaw components. With Store you can get() and set() the value separately. But it does not expose this as normal ReadSignal and WriteSignal. So we can't simply use them with thaw (I think).

Something like this.

#[derive(Debug, Store, Clone)]
struct StoreInfo {
    my_str: String,
}

#[component]
fn store_example() -> impl IntoView {
    let store = Store::new(StoreInfo {my_str: String::from("test")});
    
    view! {
        <Field label="Label">
            <Input value=store.my_str()/>
        </Field>
    }
}
@luoxiaozero luoxiaozero added the enhancement New feature or request label Nov 18, 2024
@tqwewe
Copy link
Contributor

tqwewe commented Nov 19, 2024

I'd just like to share this commit I've made on a local fork:
tqwewe@83889f7

I think instead of using a store value directly like this, instead it should be more targeted towards Field in leptos 0.7. Store is more for a complex data structure, whereas field is a single field within a store. Field also implements From<Store>.

There is one issue with my commit on line 146 where Field doesn't implement Update, however this should be fixed with leptos-rs/leptos#3257

@luoxiaozero luoxiaozero linked a pull request Nov 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants