Skip to content

Weak signals as counterparts to Arc signals #4231

@StarGuardian

Description

@StarGuardian

Is your feature request related to a problem? Please describe.

I am trying to write a function which transforms Vec<T> into Vec<(Key, ArcReadSignal<T>)> (where Key is type of ID of T) to use it in <For /> component.

I would like to place (ArcReadSignal, ArcWriteSignal) pairs into HashMap and use them to update the data if the ID has not changed.
However I don't want the HashMap to own signals, because in that case they would never be freed leading to memory leak.

Describe the solution you'd like
If there were Weak signals I would use them in the HashMap and check if them can be upgraded before use (similar to how Arc/Weak references work)

Describe alternatives you've considered
I can use Rc and Weak, but this approach is less efficient

Additional context
I can implement this and create a PR if you agree it is a good idea.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions