Skip to content

Support Shallow Reactivity for Model Fields #2002

@alexbidenko

Description

@alexbidenko

Describe the feature

Currently, pinia-orm does not provide a way to store values in model fields that should avoid deep reactivity. Most field definitions either assume primitive types or wrap the value in a deeply reactive Proxy, which can break the expected behavior of complex objects.

Use case example

In my case, I needed to create a model to store WebRTC connection objects, such as RTCPeerConnection. When I define a field using Attr, the value becomes deeply reactive, which breaks the internal behavior of the RTCPeerConnection instance.
If I skip defining the field (i.e., omit the type), then the property becomes invisible when using the model, which is also problematic.

Proposal

It would be highly beneficial to support shallow reactivity for such fields — similar to how shallowRef works compared to ref in Vue. This would give developers the flexibility to store complex structures in models without unwanted reactivity, preserving their original behavior.

Additional information

  • Would you be willing to help implement this feature?

Final checks

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions