Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Automatic update for related? #274

Open
DenisaHalmaghi opened this issue Oct 28, 2020 · 1 comment
Open

Automatic update for related? #274

DenisaHalmaghi opened this issue Oct 28, 2020 · 1 comment

Comments

@DenisaHalmaghi
Copy link

Hello there!

I'm a bit confused about a feature.

I've noticed that the state object has each resource mapped to a property (such as "comments") . These properties have other properties such as "records", "related" , "filtered" etc. However , when i create a resource, the related property (on which my computed property depends) is not updated, hence the component is not re-rendering. If i were to use an "all" getter("comments/all") instead, this would work perfectly fine, however, it is not the case in this component.

Is there a way in which i can specify which property should update? I could not seem to find any information related to this in the documentation . Am i missing something or is this an issue? If it's an issue , my team and I would be happy to contribute.

Here is some sample code to illustrate what i mean:

...
methods: {
    ...mapActions({
      createComment: 'comments/create',
      deleteComment: 'comments/delete',
      loadRelatedComments: 'comments/loadRelated',
    }),
   createComment() {
      this.createComment({
        attributes: {
         ...
        },
      });
    },
},
computed: {
    ...mapGetters({
      relatedComments: 'comments/related',
    }),
   parent() {
      return {
        type: this.parentType,
        id: this.parentId,
      };
    },
   comments() {
      return this.relatedComments({ parent: this.parent });
    },
 }

P.S. I know that in this case i could use lastCreated, but I am wondering if there's a way for the component to automatically update (like it does if i use the "comments/all" getter), without my interceding. The same goes for deleting.

Thank you for your time!

@DenisaHalmaghi DenisaHalmaghi changed the title Automatic update for related Automatic update for related? Oct 28, 2020
@CodingItWrong
Copy link
Contributor

FYI, this library will be unmaintained going forward.

If you need new features or fixes, I recommend forking the repo and making changes, or finding an alternate library that meets your needs.

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

No branches or pull requests

2 participants