dimanche 16 décembre 2018

How to maintain master data in frontend?

For example, I have a group master data, which is an array like

{[id: 1, name: `groupA`], [id: 2, name: `groupB`].....}

This array is used in many pages, like /users, /posts, etc.

So in every page I will request /api/groups to get the newest group and store it into this.$store.data.group.

The group data changes from time to time, and sometimes it will remain the same for a while.

If I check the existence of this.$store.data.group, and only request /api/groups if it does not exist, I might get some staled group data.

I was wondering is there any more efficient way to do this, avoid requesting /api/groups every time?

What is the recommended way doing this?




Aucun commentaire:

Enregistrer un commentaire