candlefinance / cache

A key/value store for React Native
https://candle.fi
MIT License
62 stars 1 forks source link

Make API compatible with AsyncStorage #2

Closed K4CZP3R closed 4 months ago

K4CZP3R commented 4 months ago

Great library!

Only thing I am missing is the API compatibility with AsyncStorage for seamless replace.

For example, Supabase library expects storage object to have the following functions: removeItem, setItem and getItem.

Workaround for now is to create a wrapper function like this:

const wrappedCacheStore = {
  getItem: async (key: string) => {
    return await read(key);
  },
  setItem: async (key: string, value: string) => {
    await write(key, value);
  },
  removeItem: async (key: string) => {
    await remove(key);
  },
};
gtokman commented 4 months ago

That sounds good. I'm happy to accept a PR. You'd have to go into the index.tsx and export that type.