Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.36 KB

api.md

File metadata and controls

46 lines (31 loc) · 1.36 KB

CycleStorage object API

storageDriver(request$)

Storage Driver.

This is a localStorage and sessionStorage Driver for Cycle.js apps. The driver is also a function, and it takes a stream of requests as input, and returns a responseCollection with functions that allow reading from the storage objects. The functions on the responseCollection return streams of the storage data that was requested.

Requests. The stream of requests should emit objects. These should be instructions to write to the desired Storage object. Here are the request object properties:

  • target (String): type of storage, can be local or session, defaults to local.
  • action (String): type of action, can be setItem, removeItem or clear, defaults to setItem.
  • key (String): storage key.
  • value (String): storage value.

responseCollection. The responseCollection is an Object that exposes functions to read from local- and sessionStorage.

// Returns key of nth localStorage value.
responseCollection.local.getKey(n)
// Returns localStorage value of `key`.
responseCollection.local.getItem(key)

Arguments:

  • request$ - a stream of write request objects.

Return:

(Object) the response collection containing functions for reading from storage.