Check out a free preview of the full Vuex for Intermediate Vue 2 Developers course

The "Local Storage Plugin" Lesson is part of the full, Vuex for Intermediate Vue 2 Developers course featured in this preview video. Here's what you'd learn in this lesson:

Divya answers questions about the way the localStorage plugin loads data, the chronology of the before and after methods, and whether or not they follow the action like a promise.

Preview
Close

Transcript from the "Local Storage Plugin" Lesson

[00:00:00]
>> The question was regarding whether or not we are grabbing the item from local storage or not and we are not. We're just sending it at the moment, you can easily grab the item from local storage. And you could do that in your plugin. It's not very useful in your plugin because we're not really doing anything with it.

[00:00:22]
The idea of a persistent state is to essentially grab information back so we can in the component itself, let's say in actions we can do, let's say yet initial state. And then you could do a local storage, get item and then I think it was last service or something like that.

[00:00:58]
So you could grab it and then you could do whatever you want with it's essentially a date object or whatever you wanna do with it. And then you can set it to the mutation which is update service date. So you could just do like this dot. I mean dispatch, commit, not dispatch commit, updateServiceDate, and then you would pass in like the payload time.

[00:01:35]
Yeah, so we didn't do that in the code, we didn't fetch from local storage we're just setting local storage, but yeah, you can easily do that.
>> What is the timeline for before and after is it as if before method content is pasted at the start of the action body and after content is based at the end or is it follow like in follow the action like a promise.

[00:02:02]
>> Doesn't follow the action like a promise. I believe it follows the action like a promise. So it's like the before which is right before it gets dispatched. And then the after is when whatever happens within the actions finishes right before it calls commit to the next mutation.

[00:02:23]
So that's the after. So once it does everything that's sort of the timeline between before and after

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now