Skip to content

computed variable with arrow functions (second argument on setter) #7688

Closed
@ibyteyou

Description

@ibyteyou

What problem does this feature solve?

One guy finded, that computed getter may use with arrow function and destructed variables/methods.

I went ahead, and appended this case to set(), but failed, because setter not called component.
Later, i tried use arguments: (locale => arguments[1].a.methods.updateLocale(locale)), but vuex can't use dispatch to this, because undefined.

I think this API looks nice and will reduce many new lines :D

What does the proposed API look like?

export default {
  computed: {
    ...mapGetters(['global']),
    locale: {
      get: ({ global }) => global.locale,
      set: (locale, { updateLocale }) => updateLocale(locale)
    }
  },
  methods: {
    ...mapActions(['updateLocale'])
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions