Skip to content

helielson/rn-relay-cache-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rn-relay-cache-manager

A RelayCacheManager implementation for local data caching on React Native apps. Based on relay-cache-manager.

Overview

Relay defines the CacheManager interface which lets you write and read records to a local cache. Relay will check the cache first when identifying what data it has/needs; by implementing a CacheManager you can render locally cached data quickly while Relay queries your API and updates the data when the response comes in.

Install

$ npm install --save rn-relay-cache-manager

Usage

Just create a instance of CacheManager and inject it to the Relay Store:

import CacheManager from 'rn-relay-cache-manager';

const cacheKey = '__cache_key__';
const cachedData = await AsyncStorage.getItem(cacheKey);

const cacheManager = new CacheManager({
  cacheKey, // optional
  cachedData, // optional
  storage: AsyncStorage, // default
});
Relay.Store.injectCacheManager(cacheManager);

Options

  • cacheKey: (optional) A string with the key used by storage to read/write data. Default value: __RelayCache__.
  • cachedData: (optional) The loaded cache object
  • storage: The key-value persistent system that the cache manage will use. Default value: AsyncStorage from react-native.

TODO

  • Add an example
  • Write tests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published