Persistence API Reference

Classes

class PersistenceService(The, Object, str)

A client for the thiss.io persistence service. The Persistence service methods all follow the same pattern - a call that returns a Promise that resolves to one or more item Objects. An item is an Object with two properties:

The constructor initializes an iframe in window.document setting src to the URL provided to the constructor.

Arguments:
  • The (url) – URL of the persistence service - eg https://use.thiss.io/ps/
  • Object (opts) – An object containing options. Supported keys:
  • str (opts.apikey) – An optional API-key
PersistenceService.PersistenceService

The constructor initializes an iframe in window.document setting src to the URL provided to the constructor.

PersistenceService.entities(str)

Returns 0-3 of the most recently used entities as a list of item Objects. Be sure to examine the last_time property to make sure the provided entities are “recent” enough to be used.

Arguments:
  • str (context) – The context to write to
Returns:

Promise – A Promise that resolves to a list of items on success.

PersistenceService.entity(string)

Fetch an entity from the context.

Arguments:
  • string (entity_id) – The entityID of the item to be removed.
Returns:

Promise – A Promise that resolves to an item containing the entity on success.

PersistenceService.remove(string)

Remove an entity from the context.

Arguments:
  • string (entity_id) – The entityID of the item to be removed.
Returns:

Promise – A Promise that resolves to nothing on success.

PersistenceService.update(str, Object)

Update an an entity object in browser local store tied to the ORIGIN of the service URL.

Arguments:
  • str (context) – The context to write to
  • Object (entity) – A js object representing an entity. Uses the discojson schema.
Returns:

Promise – A Promise that resolves to an item containing the provided entity on success.