Closed andrewzey closed 4 years ago
Resolves https://github.com/robwalkerco/redux-persist-filesystem-storage/issues/47
Using in our react-native project.
react-native
Confirmed that The API mirrors AsyncStorage:
AsyncStorage
(async () => { console.log('asyncStorage getItem: ', await AsyncStorage.getItem('foo')); console.log('filesystemStorage getItem: ', await FilesystemStorage.getItem('foo')); console.log('asyncStorage removeItem: ', await AsyncStorage.removeItem('bar')); console.log('filesystemStorage removeItem: ', await FilesystemStorage.removeItem('bar')); })();
getItem checks for existance in the catch block to reduce unneeded file system access.
getItem
removeItem could not do the same, as unlink doesn't throw when the file doesn't exist, it just returned undefined (whereas AsyncStorage returns null)
removeItem
unlink
undefined
null
Thanks for your PR @andrewzey
Glad to help!
Resolves https://github.com/robwalkerco/redux-persist-filesystem-storage/issues/47
Using in our
react-native
project.Confirmed that The API mirrors
AsyncStorage
:getItem
checks for existance in the catch block to reduce unneeded file system access.removeItem
could not do the same, asunlink
doesn't throw when the file doesn't exist, it just returnedundefined
(whereasAsyncStorage
returnsnull
)