Skip to content

should the get() component helper reference getters, vis-a-vis variable expansion #85

@shasderias

Description

@shasderias

Thank you for the library! Ran into a "problem" when using the get() component helper. Not sure if a change is necessary (other than perhaps clarifying the documentation). For your consideration.

When used as a component helper, it seems that:

  1. get() references getters and state; and
  2. sync() references state only.

I think in line with Pathify's accessor priority, this is fine. But when the path passed to get() references a getter and there is a variable to be expanded in the path, get() does not work. See the following link for a repro:

Code Sandbox

There are a few distinct issues that might be worth addressing here:

  • conceptually, should get() (when used as a component helper) reference getters?
  • if the above is true, how should get() deal with variable expansion when referencing getters?
  • if variable expansion is not meant to work when referencing a getter, perhaps Pathify should return an error, currently, get() fails silently and always returns undefined
  • if nothing else, the documentation for variable expansion could be clearer in this regard (https://davestewart.github.io/vuex-pathify/#/api/paths)
  • the documentation states "when getting, only state will be referenced; getters will be ignored", right below an example of get(), when this is only true for sync()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions