Dashboard-Plugin
Docs HomeDashboard plugins and appsInfomakerNaviga global
  • About
  • Intro
  • Getting started
  • The anatomy of a plugin
  • Manifest structure
  • Getting started
    • Get Dashboard-Plugin
    • Build
  • What's new
  • Components
    • Agent
      • Actions
    • Application
    • Widget
    • Health
    • Modal
    • Settings
  • API and GUI
    • API
      • Overview
      • register
        • Reducers
        • Portals
        • Requirements
        • Permissions
        • Default config
        • Config Modifiers
      • cache
      • store
      • encrypt
      • decrypt
      • createUUID
      • getLanguage
      • getTextDirection
      • getTimeFormat
      • getKeyCharFromCode
      • getKeyCodeFromChar
      • event
      • Logger
      • buildRouteUrlWithDispatchableEvent
      • getUser
      • getAction
      • getPortal
      • getConfig
      • getLocalize
      • getAvailableActions
      • getAvailablePortals
      • request
      • setHealth
      • openModal
      • closeModal
      • confirm
      • notifications
      • hasPermission
      • standalone
      • withUser
      • useModal
      • useSheet
      • useUser
      • useConfig
      • useLocalize
      • useApplication
      • useMappings
      • useStandalone
    • GUI
      • Core GUI
      • Style-Guide
    • Modules
      • GUI
      • Utility
      • NavigaID
        • getUserToken
        • getApplicationToken
        • getGroupsFromToken
  • Mappings
  • Plugins deployments
  • S3 upload
  • Deprecations
    • 4.1.0
    • 4.0.0
    • 2.1.0
Powered by GitBook
On this page
  • How to use
  • Cache payload
  • Save data to localStorage
  • Get data from localStorage
  • Remove data from localStorage

Was this helpful?

  1. API and GUI
  2. API

cache

handle storing data to localStorage

How to use

import { Plugin } from '@root'

Plugin.cache({
    ...CACHE_PAYLOAD
})

Cache payload

Param

Typeof

Default

Required

Description

key

String

null

✅

the cache key to be used to save/get/remove your data from localStorage.

data

Any

null

✅

the data item to be stored.

expire

Number

0

❌

when the data should be expired in localStorage

callback

Function

null

❌

a callback will be called when the data is saved/removed from localStorage

method

String

GET

❌

a method to save/get/remove available: GET, POST, DELETE

Save data to localStorage

import { Plugin } from '@root'

const item = {
    id: 'item-id',
    name: 'item name'
}

const onSave = () => {

}

Plugin.cache({
    key: 'my-cache-key',
    data: item,
    method: 'POST',
    callback: onSave
})

Get data from localStorage

import { Plugin } from '@root'

const onGet = cachedData => {
    console.log(cachedData)
    /*
        Output:
        {
            id: 'item-id',
            name: 'item name'
        }
    */
}

Plugin.cache({
    key: 'my-cache-key',
    method: 'GET', // can be ignored, as GET is the default method for cache
    callback: onGet
})

Remove data from localStorage

import { Plugin } from '@root'

Plugin.cache({
    key: 'my-cache-key',
    method: 'DELETE'
})
PreviousConfig ModifiersNextstore

Last updated 4 years ago

Was this helpful?