0.2.1 • Published 3 years ago

@galaxis/in-memory-cache v0.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Galaxis In-Memory Cache

npm

A Galaxis cache that stores state in memory and is observable via Redux DevTools.

Installation

yarn add @galaxis/in-memory-cache

You need to install Galaxis Core as well, directly or indirectly.

The library is compiled to modern JS, but it should work in all reasonable browsers with the help of properly configured Babel.

Public API

⚠ Anything that is not documented here is not considered a part of public API and may change at any time.

InMemoryCache

Implements Cache.

const inMemoryCache = new InMemoryCache({ emptyData, initialState, enableDevTools });
Arguments
NameTypeDescriptionRequired
emptyDataCA value that conforms to C, that is considered to be empty. E.g. {entities: {}}Yes
initialStateCacheState<C, ErrorObject >A value from cache.extract(), most likely from SSR.No
enableDevToolsbooleanEnable Redux DevTools integration.No

cache.extract()

Returns the cache state in serializable form. Uses serialize-error to convert errors into serializable objects.

const state = cache.extract();
Return value

CacheState<C, ErrorObject >

Important types

CacheState

Internal state of the cache.

NameTypeDescription
dataCCache data.
errorsRecord<string, E | undefined>Cached errors. E is Error by default.