Improve progress reporting example. Refs #7693

This commit is contained in:
Dominik Picheta 2018-04-25 22:49:29 +01:00 • committed by GitHub
commit d01b1558a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,12 +74,17 @@
## ##
## .. code-block:: Nim ## .. code-block:: Nim
## import asyncdispatch, httpclient ## import asyncdispatch, httpclient
## var client = newAsyncHttpClient() ##
## proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = ## proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} =
## echo("Downloaded ", progress, " of ", total) ## echo("Downloaded ", progress, " of ", total)
## echo("Current rate: ", speed div 1000, "kb/s") ## echo("Current rate: ", speed div 1000, "kb/s")
##
## proc asyncProc() {.async.} =
## var client = newAsyncHttpClient()
## client.onProgressChanged = onProgressChanged ## client.onProgressChanged = onProgressChanged
## discard waitFor client.getContent("http://speedtest-ams2.digitalocean.com/100mb.test") ## discard await client.getContent("http://speedtest-ams2.digitalocean.com/100mb.test")
##
## waitFor asyncProc()
## ##
## If you would like to remove the callback simply set it to ``nil``. ## If you would like to remove the callback simply set it to ``nil``.
## ##