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

Also cache requests with parameters #5

Closed
eele94 opened this issue Feb 8, 2018 · 3 comments
Closed

Also cache requests with parameters #5

eele94 opened this issue Feb 8, 2018 · 3 comments

Comments

@eele94
Copy link

eele94 commented Feb 8, 2018

Hello I have a feature request for vuex-cache

An idea to cache also the requests with parameters?

'use strict';

var index = (function (store) {
  store.cache = new Map();

  store.cache.dispatch = function () {
    var type = arguments[0];
    if (arguments[1]) {
      type = type + JSON.stringify(arguments[1]);
    }
    if (!store.cache.has(type)) {
      store.cache.set(type, store.dispatch.apply(store, arguments));
    }
    return store.cache.get(type);
  };
});

module.exports = index;

@superwf
Copy link
Owner

superwf commented Feb 11, 2018

update to 1.1.0 with the support for params.
thanks

@eele94
Copy link
Author

eele94 commented Feb 15, 2018

What is the difference with your code for arguments and mine? Why chose your solution?

@superwf
Copy link
Owner

superwf commented Feb 20, 2018

I add some detail for the cache 'get', 'has', 'delete' and 'clear' api methods.

@superwf superwf closed this as completed Feb 20, 2018
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