Skip to content

Instantly share code, notes, and snippets.

@jeroen
Created January 13, 2019 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroen/81ede584123094eb25a7ea22a0976863 to your computer and use it in GitHub Desktop.
Save jeroen/81ede584123094eb25a7ea22a0976863 to your computer and use it in GitHub Desktop.
parse_streamer <- function(url, cb = print){
con <- curl::curl(url = url)
open(con)
on.exit(close(con))
repeat{
txt <- readLines(con, 1)
if(!length(txt)){
print("All done!")
cb(NULL)
break;
}
if(grepl("^data:", txt)){
json <- sub("^data:", "", txt)
data <- jsonlite::fromJSON(json)
cb(data)
}
}
}
parse_streamer('https://mybinder.org/build/gh/karthik/binder-test-fastest/master')
@karthik
Copy link

karthik commented Jan 13, 2019

Worked perfectly, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment