Created
February 9, 2018 01:19
-
-
Save jimmed/a9a901e61cd830dd91441bb0a1ae694c to your computer and use it in GitHub Desktop.
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
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