2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-09 23:00:56 +00:00

Add disableStorage function to SVG framework

This commit is contained in:
Vjacheslav Trushkin 2020-08-12 21:21:20 +03:00
parent 2a1b3a2b8b
commit 0f3457b6ee
2 changed files with 23 additions and 15 deletions

View File

@ -112,18 +112,7 @@ export interface IconifyGlobal extends IconifyGlobal1, IconifyGlobal2 {}
// Export dependencies
export { IconifyGlobal as IconifyGlobalCommon, IconifyAPI };
/**
* Global variable
*/
const Iconify: IconifyGlobal = ({
// Load icons
loadIcons: API.loadIcons,
// API providers
addAPIProvider: setAPIConfig,
// Allow storage
enableCache: (storage: IconifyCacheType, value: boolean) => {
function toggleCache(storage: IconifyCacheType, value: boolean): void {
switch (storage) {
case 'local':
case 'session':
@ -136,6 +125,24 @@ const Iconify: IconifyGlobal = ({
}
break;
}
}
/**
* Global variable
*/
const Iconify: IconifyGlobal = ({
// Load icons
loadIcons: API.loadIcons,
// API providers
addAPIProvider: setAPIConfig,
// Toggle storage
enableCache: (storage: IconifyCacheType, value?: boolean) => {
toggleCache(storage, typeof value === 'boolean' ? value : true);
},
disableCache: (storage: IconifyCacheType) => {
toggleCache(storage, false);
},
// Exposed internal functions

View File

@ -20,7 +20,8 @@ export interface IconifyAPI {
/**
* Toggle local and session storage
*/
enableCache: (storage: IconifyCacheType, value: boolean) => void;
enableCache: (storage: IconifyCacheType, value?: boolean) => void;
disableCache: (storage: IconifyCacheType) => void;
/**
* Load icons