Skip to content

Vue and useVModel update #1150

@egoson

Description

@egoson

Proposal

Currently, unsubscribing in the model is only possible within a Vue component on the unMounted event. However, we cannot exclude the case when Effector might be used in a composable, in which case the unMounted event might never occur. I have added the effectScope method, which allows you to unsubscribe at any moment upon request.

In its current form, useVModel has an optional argument effectScope(scope). Unsubscription occurs either on the scope.stop() event or on the unMounted event within the same onScopeDispose call, making this solution backward compatible.

A few more improvements:

  1. Fixed type inference when $store is passed to useVModel. A similar issue was observed in this issue.
  2. Updated the deepCopy function; instead of array.find, the new Map().get method is now used. However, I would also consider how we can do without it.
  3. Removed unnecessary reactive wrappers in useVModel.

Use case

Any use of useVModel in Vue composables without Vue components.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for Commentseffector-vueeffector-vue package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions