Local Storage

Block Group: Browser API
Icon:Local Storage block icon

Allows your project to store information in the user’s browser, over multiple sessions and browser windows.

For information on using dataflow blocks, see Dataflow.


Input/Output Properties

These properties can take input and give output.

  • key (string)
  • global (boolean)
  • value (string or multi-line text input)

key sets or returns the key for a key-value pair.

global specifies whether this block sets and returns the global or non-global value for the key.

  • TRUE: This block sets and returns this user’s global value for the key, which stays consistent over any DGLux5 project.
  • FALSE: This block sets and returns this user’s non-global value for the key, which applies only to this DGLux5 project.

value sets or returns the value for a key-value pair.


Remarks

  • To store multiple key-value pairs, use multiple blocks.

Model

This is a basic use of the block.

Dataflow Model Description
Local Storage dataflow model The user's selection of the Weekly option for a chart's rollup type is bound to the Local Storage block's value property. This choice is remembered if the user opens a new window or starts a new session.

Use Case

This section covers how to pass a value into a Local Storage block using JavaScript.

Changes to value from JavaScript do not take effect if the JavaScript is in the developer console for the same DGLux5 frame. Changes take effect only if the JavaScript is in an IFrame, or a different .dg5 file from the Local Storage block.

To pass a value into a Local Storage block:

  1. Create a Local Storage block, and define the global and key properties.
  2. Use the following syntax to append code to define the value:

    window.localStorage['dg:project:key1'] = "value1";
    • Replace project with the name of the project. If global is set to TRUE, project is blank, so the syntax is dg::key1.
    • Replace key1 with the name of the key. This must match the key property of the Local Storage block.
    • Replace value1 with the value of the key.

More Resources

This thread in the DGLogik Community Forum addresses the local storage block: