CycleStorage object API
November 16, 2017 ยท View on GitHub
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 belocalorsession, defaults tolocal.action(String): type of action, can besetItem,removeItemorclear, defaults tosetItem.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.