Skip to content

Instantly share code, notes, and snippets.

@jimmed
Created February 9, 2018 01:19
Show Gist options
  • Save jimmed/a9a901e61cd830dd91441bb0a1ae694c to your computer and use it in GitHub Desktop.
Save jimmed/a9a901e61cd830dd91441bb0a1ae694c to your computer and use it in GitHub Desktop.
let lastRequestId = 0
const searchRequest = (query) => {
const requestId = ++lastRequestId
// fetch results somehow, and then...
return fetchSearchResults(query)
.then(results => {
if (requestId === lastRequestId) {
performStateUpdate(results) // do your state updates here
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment