morrys / wora

Write Once, Render Anywhere. typescript libraries: cache-persist, apollo-offline, relay-offline, offline-first, apollo-cache, relay-store, netinfo, detect-network
https://morrys.github.io/wora/docs/introduction
MIT License
174 stars 4 forks source link

bumping async storage #76

Closed GregoryCollett closed 3 years ago

GregoryCollett commented 3 years ago

@react-native-community/async-storage is now deprecated.

morrys commented 3 years ago

Hi @GregoryCollett, thanks for your PR.

Since even expo is now compatible with react-native-async-storage/async-storage https://docs.expo.io/versions/latest/sdk/async-storage/

I would change createStorage.native.ts like this:

import { ICacheStorage } from './CacheTypes';
import AsyncStorage from '@react-native-async-storage/async-storage';

/**
 * I had to restore the abstraction above the AsyncStorage for a
 * typescript problem in the multiGet (readonly parameter)
 *
 */

export function createStorage(_type): ICacheStorage {
    return {
        multiRemove: (keys) => AsyncStorage.multiRemove(keys),
        multiGet: (keys) => AsyncStorage.multiGet(keys),
        getAllKeys: () => AsyncStorage.getAllKeys(),
        multiSet: (items) => AsyncStorage.multiSet(items),
        setItem: (key, value) => AsyncStorage.setItem(key, value),
        removeItem: (key) => AsyncStorage.removeItem(key),
        getItem: (key) => AsyncStorage.getItem(key),
    } as ICacheStorage;
}

What do you think about it?

GregoryCollett commented 3 years ago

Hi @morrys,

Great shout, I have updated the pr to reflect this change.

GregoryCollett commented 3 years ago

Thanks!

morrys commented 3 years ago

thank you for your contribution 💯

I will release the libraries as soon as possible.

Can I ask you which library are you using?