Giter Site home page Giter Site logo

Comments (2)

johnpapa avatar johnpapa commented on August 13, 2024

Nice catch. There are a few things at work here.

1 - The action deletes the hero in the data source. Then it passes the hero id to the mutation, which then tries to find that hero to delete it from the store (this fails to find one and moves along). Then the component re-loads the heroes in the store by querying the data source. This is why it "seems" to work and I missed this originally. The net result is the same, but it is misleading, and this is why you were confused on closer inspection of the code. Nice catch!

2 - The component does not need to reload the heroes. I added this code because despite the delete of the hero in the store (which wasnt happening, but should have been) ,there is a chance that another user modifies the database and this reload will get any changes. I added a comment to clarify this in the code as I do think it's a good practice. 9d1b333

3 - The fix I implemented is to pass the hero object from the action to the mutation. This is also in this commit 9d1b333

Thanks for the raising this!

from vue-getting-started.

kRapaille avatar kRapaille commented on August 13, 2024

I'm glad I wasn't crazy :) I, indeed, missed the reload in the method. It explains a lot.

Thank you !

from vue-getting-started.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.