sham-ui-data-storage v3.0.0
sham-ui-data-storage
Data storage for sham-ui
Install
# npm
npm install -D sham-ui-data-storage# yarn
yarn add sham-ui-data-storage --devAPI
Table of Contents
StorageGetter
Getter for storage
Type: Function
Parameters
DIObject
Returns Storage
CreateStorageOptions
Options for createStorage
Type: Object
Properties
DIstring Registry storage in DI with this key. By default usestorage:<random key>as key.LIFOboolean Use LIFO (last input first output) for storage subscribers. By default falsesyncboolean Disable async run watchers callback. Callbacks will run only after callsyncstorage method. By default false
createStorage
Create a new unique storage object for current DI.
Parameters
fieldsWithDefaultObject Fields of storageoptionsCreateStorageOptions? Extra options for storage (optional, default{})
Examples
import createStorage from 'sham-ui-data-storage';
export const { storage, useStorage } = createStorage( {
name: '',
email: '',
sessionValidated: false,
isAuthenticated: false
}, { DI: 'session:storage' } );Returns {storage: StorageGetter, useStorage: (function ())}
storage
Return storage for DI container
Parameters
DIObject App DI container
Returns Storage
useStorage
Decorator for component
Parameters
storageAliasstring Name of classProperty for access to storage fields
Examples
<template>
<span class="logged-name">
{{sessionData.name}}
</span>
</template>
<script>
import { useStorage } from '../../../storages/session';
function Profile {
}
export default Component( Template, useStorage( ref( 'sessionData' ) ), Profile );
</script>Returns Function
Storage
Type: Object
addWatcher
Add watcher for field
Parameters
removeWatcher
Remove watcher for field
Parameters
reset
Remove all watchers & reset storage field to default values
sync
Run all deferred subscribers immediate
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago