Skip to content

Instantly share code, notes, and snippets.

@mcavaliere
Last active July 2, 2018 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcavaliere/5ff291c7d30198c7e174ac7fd233794c to your computer and use it in GitHub Desktop.
Save mcavaliere/5ff291c7d30198c7e174ac7fd233794c to your computer and use it in GitHub Desktop.
Workaround for promise issues with AsyncStorage multiSet/multiGet/multiRemove in React Native (unresolved as of 2018-07-02). See: https://github.com/facebook/react-native/issues/14101
export default class AsyncStorageSupplement {
static multiGet(keys) {
return Promise.all(
keys.map(key => AsyncStorage.getItem(key))
)
}
static multiRemove(keys) {
return Promise.all(
keys.map(key => AsyncStorage.removeItem(key))
)
}
static multiSet(pairs) {
return Promise.all(
pairs.map(pair => AsyncStorage.setItem(pair[0], pair[1]))
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment