Skip to content

Instantly share code, notes, and snippets.

@ridhotegar
Last active December 23, 2021 05:01
Show Gist options
  • Save ridhotegar/bfa78e31c42491bac58e0d40c3c86de7 to your computer and use it in GitHub Desktop.
Save ridhotegar/bfa78e31c42491bac58e0d40c3c86de7 to your computer and use it in GitHub Desktop.
Wait all localStorage done with promise
const localSet = (key, value) => {
    return new Promise(resolve => {
        resolve(localStorage.setItem(key, value))
    })
}
Promise.all([
localSet('KeyA', 'ValueA'),
localSet('KeyB', 'ValueB'),
localSet('KeyC', 'ValueC')
]).then(()=>{
console.log(localStorage)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment