Skip to content

Instantly share code, notes, and snippets.

@tfiechowski
Last active January 7, 2021 20:39
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 tfiechowski/db0ba9fb3540e354cc59832624a4fead to your computer and use it in GitHub Desktop.
Save tfiechowski/db0ba9fb3540e354cc59832624a4fead to your computer and use it in GitHub Desktop.
const performUpdates = useDebouncedCallback(
async () => {
if (!hasPendingUpdates(pendingUpdates)) {
return;
}
clearPendingUpdates();
applyUpdatesToPhotos(pendingUpdates);
try {
const pendingUpdatesList = Object.keys(pendingUpdates);
await onUpdate(pendingUpdatesList);
removePhotosLockedFlag(pendingUpdates);
} catch (exception) {
revertPhotosToOriginalState(photos);
}
},
DEBOUNCED_BATCH_TIMEOUT,
{ maxWait: 2500 }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment