MitsuhaKitsune / vuex-webextensions

A Vuex plugin to share store through webextensions components
MIT License
83 stars 30 forks source link

Usage of persistentStates with modules #25

Closed bbird1980 closed 3 years ago

bbird1980 commented 5 years ago

I have module "player" and one of state keys "volume" and want to persist only this key, to make this happens i updated utils.filterObject

import { get, set } from 'lodash-es';

function filterObject(source, keys) {
  const newObject = {};
  keys.forEach(key => {
    const value = get(source, key);
    if (typeof value !== 'undefined') {
      set(newObject, key, value);
    }
  });
  return newObject;
}

export {filterObject};

now we can use path in keys: VuexWebExtensions({ persistentStates: ['player.volume'] })

MitsuhaKitsune commented 4 years ago

I gona check it now, on your hint you use lodash as dependency for get and set.

For reduce to max the risk of vulnerability on the plugin and his size too, I always try to avoid external dependencies, I gona try to fix it with my own methods first instead use lodash.

culttm commented 4 years ago

What about this feature? This one will be really useful while using modules in a store

quanengineering commented 4 years ago

@MitsuhaKitsune Could you check this feature? I think this one is useful.