christianmalek / vuex-rest-api

A utility to simplify the use of REST APIs with Vuex
http://vuex-rest-api.org
MIT License
382 stars 48 forks source link

Optimistic updates - beforeRequest #70

Closed BorisTB closed 6 years ago

BorisTB commented 6 years ago

Hi, first of all, thank you for this amazing tool.

There's just one thing I miss in this library.. is it possible to implement option to do changes to store before request is sent? E.g. I want to delete table row in view as soon as users clicks on delete, and if request fails then I'll add that row back to store.

Something like beforeRequest or optimisticUpdate option.

christianmalek commented 6 years ago

Hello!

This is not possible at the moment. But an "before request" option could be easily implemented. Maybe someone (you?) will provide it via an PR?

BorisTB commented 6 years ago

I'm not really skilled with typescript, but this works for me: https://github.com/christianmalek/vuex-rest-api/pull/71/files

christianmalek commented 6 years ago

Hey! Thanks for your PR. I'll test it and respond to you in ~1 week.

christianmalek commented 6 years ago

I've merged it in version 2.9.0. Thanks again for your contrib!