Skip to content

Instantly share code, notes, and snippets.

@joshbedo
Created March 20, 2015 15:30
Show Gist options
  • Save joshbedo/64dc4f60d1d97ba6c332 to your computer and use it in GitHub Desktop.
Save joshbedo/64dc4f60d1d97ba6c332 to your computer and use it in GitHub Desktop.
long-polling React
@ProgressBar = ProgressBar({ pending: file_export.completed_items, total: file_export.total_items })
if @inProgress(file_export)
do poll = () =>
setTimeout (=>
debugger
$.ajax(
url: '/api/v1/file_exports.json',
success: (data) =>
@ProgressBar.setState({ pending: data.completed_items })
error: (data) =>
console.log('error')
complete: poll
)
), 5000, this
return @ProgressBar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment