@mudas/util-store
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

util-store

npm version

A tools for incremental storage in store, and module merge and other transactions

Setup

install:

npm i @mudas/util-store -S

You need to add configuration for vue-cli to correctly translate the es module in node_modules:

// vue.config.js:
module.exports = {
    transpileDependencies: [
      '@mudas/*' // all of node_module for '@mudas'
    ]
}

Usage

directory Structure:

env
  |- index.js
  |- env1.js
  └─ env2.js

env/env1.js:

import * as utils from '@mudas/util-store';

const Mutations = {
  [ENV_INFO](state, data) {
    // Incremental save
    // existing field values are overwritten, non-existent fields are created
    utils.increment(state.envInfo, data);
    
    // Simple value type or null, no need to use incremental save
    // please use the fllowing code, direct assignment:
    // state.envInfo = 1; // null, true, 'any'
  }
};

env/index.js:

import * as utils from '@mudas/util-store';
import EnvInfo1 from './env1';
import EnvInfo2 from './env2';

// Combine multiple StoreOptions into a single StoreOptions
export default utils.mergeStore([
  EnvInfo1, 
  EnvInfo2
]);

Readme

Keywords

none

Package Sidebar

Install

npm i @mudas/util-store

Weekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

15.6 kB

Total Files

9

Last publish

Collaborators

  • mudas