1.1.5 • Published 5 years ago

edata-store v1.1.5

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

edata-store

Easily use global store with edata.

Build Status NPM Version

Install

You can install from NPM.

npm install --save edata-store

Usage

  1. Initialize store using initStore (normally at your entry file)
import {initStore} from 'edata-store'
initStore() // `'default'` namespace
// OR
initStore(`xx_space`)
  1. call getStore(), and you get an edata instance. (normally at your component file)
// any where in your source
import {getStore} from 'edata-store'
getStore().set('xx', 1)  // `'default'` namespace
getStore().get('xx').toJSON() // 1

Or pass the namespace arg:

getStore('xx_space').set('xx', 2)  // `'xx_space'` namespace
getStore('xx_space').get('xx').toJSON() // 2

Above create a separate edata under xx_space namespace.

API

The typescript definition as below:

/**
 * Initialize store for namespace, after that you can call getStore
 * @param namespace {string} The namespace of cacheStore, empty for 'default'
 * @param initData {any} The edata initData
 * @param edataOptions {IOptions} The edata Initialize IOptions
 * @returns {edataRoot} The edata root instance
 */
export declare function initStore(namespace?: string, initData?: any, edataOptions?: Partial<IOptions>): edataRoot;
/**
 * Get store using namespace from cacheStore
 * @param namespace {string} The namespace of cacheStore, empty for 'default'
 * @returns {edataRoot} The edata root instance
 */
export declare function getStore(namespace?: string): edataRoot;
1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago