Created
March 17, 2018 19:24
-
-
Save Kelin2025/b047c27d0ccb9d76abf5100e0618e6f0 to your computer and use it in GitHub Desktop.
Apicase debounce
This file contains hidden or 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
const search = doRequest({ | |
url: '/search', | |
options: { immediate: false, debounce: 2000 } | |
}) | |
/* Spamming requests while typing */ | |
search.start({ query: { text: 'H' } }) | |
search.start({ query: { text: 'He' } }) | |
search.start({ query: { text: 'Hel' } }) | |
search.start({ query: { text: 'Hell' } }) | |
search.start({ query: { text: 'Hello' } }) | |
search.start({ query: { text: 'Hello ' } }) | |
search.start({ query: { text: 'Hello w' } }) | |
search.start({ query: { text: 'Hello wo' } }) | |
search.start({ query: { text: 'Hello wor' } }) | |
search.start({ query: { text: 'Hello worl' } }) | |
search.start({ query: { text: 'Hello world' } }) | |
search.start({ query: { text: 'Hello world!' } }) | |
/* Listen when it really starts */ | |
search.on('start', console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment