Skip to content

ReadStore::from requires that the underlying Lens is Writeable #5603

Description

@MonaMayrhofer

Problem

When you have a ReadStore and use a lensing function to access one of its fields, that resulting store cannot be converted into another ReadStore.

Aka. you cannot map a ReadStore to a ReadStore

Steps To Reproduce

        #[derive(Store, Default)]
        struct Thing {
            entry: String,
        }
        let a = Store::new(Thing::default());
        let b = ReadStore::from(a);

        let b_entry = b.entry();
        let b_entry_read = ReadStore::from(b.entry());
22:41:52 [cargo] error[E0277]: the trait bound `dioxus::prelude::ReadSignal<Thing>: Writable` is not satisfied
   --> crates/story-teller-app/src/components/townsquare/seat_circle.rs:558:28
    |
558 |         let b_entry_read = ReadStore::from(b.entry());
    |                            ^^^^^^^^^ the trait `Writable` is not implemented for `dioxus::prelude::ReadSignal<Thing>`

Expected behavior

It seems to me that this should be possibe, as it feels like a common use case to receive a ReadStore in a component, and then pass a lensed ReadStore into a deeper component.

Environment:

  • Dioxus version: v0.7.1
  • Rust version: 0.97.0-nightly
  • App platform: web

Questionnaire

I'm interested in fixing this myself but don't know where to start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions