Created
April 8, 2020 11:37
-
-
Save sagarpanda/a2fd7f35a18ef4e9d1886aefa163a800 to your computer and use it in GitHub Desktop.
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 shortPolling = (fn, interval) => { | |
| let counter = 1; | |
| const _interval = interval || 1000; | |
| const next = (params) => { | |
| setTimeout(() => { | |
| counter += 1; | |
| fn(next, counter, params); | |
| }, _interval); | |
| }; | |
| fn(next, counter); | |
| }; | |
| shortPolling((next, counter) => { | |
| console.log('hello', counter); | |
| next(); | |
| }, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment