Created
July 29, 2018 10:23
-
-
Save bharathvaj-ganesan/380b37181b31b23099190a1028d07e7f to your computer and use it in GitHub Desktop.
Long Polling client
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
/* Client - subscribing to the github events */ | |
subscribe: (callback) => { | |
const pollUserEvents = () => { | |
$.ajax({ | |
method: 'GET', | |
url: 'http://localhost:8080/githubEvents', | |
success: (data) => { | |
callback(data) // process the data | |
}, | |
complete: () => { | |
pollUserEvents(); | |
}, | |
timeout: 30000 | |
}) | |
} | |
pollUserEvents() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment