Persistence Modes

Context Hub stores use one of the following persistence modes:

  • Local: Uses HTML5 localStorage to persist data. Local storage is persisted on the browser across sessions.
  • Session: Uses HTML5 sessionStorage to persist data. Session storage is persisted for the duration of the browser session and is available to all browser windows.
  • Cookie: Uses the browser’s native support of cookies for data storage. Cookie data is sent to and from the server in HTTP requests.
  • Window.name: Uses the window.name property to persist data.
  • Memory: Uses a JavaScript object to persist data.

By default, Context Hub uses the Local persistence mode. If the browser does not support or allow HTML5 localStorage, Session persistence is used. If the browser does not support or allow HTML5 sessionStorage, Window.name persistence is used.

Store Data

Internally, store data forms a tree structure, enabling values to be added as primary types or complex objects. When you add complex objects to stores, the object properties form branches in the data tree. For example, the following complex object is added to an empty store named location:

Object {
   number: 321,
   data: {
      city: "Basel",
      country: "Switzerland",
      details: {
         population: 173330,
         elevation: 260
      }
   }
}

The tree structure of the store data can be conceptualized as follows:

/
|- number
|- data
      |- city
      |- country
      |- details
            |- population
            |- elevation

The tree structure defines data items in the store as key/value pairs. In the above example, the key /number corresponds with the value 321, and the key /data/country corresponds with the value Switzerland.