Created
January 17, 2021 07:01
-
-
Save LuffyAnshul/11f23bc1628c527c5c8578d1ea46a239 to your computer and use it in GitHub Desktop.
Private Chat React Native - Functions to handle async events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function handlePress() { | |
const _id = Math.random().toString(36).substring(7); | |
const user = { _id, name }; | |
await AsyncStorage.setItem('user', JSON.stringify(user)); | |
setUser(user); | |
} | |
async function handleSend(messages) { | |
const writes = messages.map((m) => chatsRef.add(m)); | |
await Promise.all(writes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment