Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Subscribing to property of computed property #100

Open
lwansbrough opened this issue Jan 16, 2019 · 1 comment
Open

Subscribing to property of computed property #100

lwansbrough opened this issue Jan 16, 2019 · 1 comment

Comments

@lwansbrough
Copy link

I have the following scenario:

export default {
  name: 'Test',
  subscriptions () {
    return {
      test: this.project.test
    }
  },
  computed: {
    project () { return this.$store.getters['project/project'] }
  }
}

In this case, I have a store which produces the project object (not observable) with a test property (observable).

The problem is that if project changes, the subscription for test doesn't update to the new project.test -- so subsequent updates from the new project's test observable are not observed by the component.

How can this be addressed?

@regou
Copy link
Collaborator

regou commented Jan 16, 2019

If you want use observers irrelevant to a component’s lifecycle, use them without vuex

subscriptions is a .subscribe sugar in create lifecycle

If constantly switching between different observables is what you want, try switchMap

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants