Improve progress reporting example. Refs #7693
This commit is contained in:
parent
4d24eb9464
commit
d01b1558a3
1 changed files with 8 additions and 3 deletions
|
|
@ -74,12 +74,17 @@
|
|||
##
|
||||
## .. code-block:: Nim
|
||||
## import asyncdispatch, httpclient
|
||||
## var client = newAsyncHttpClient()
|
||||
##
|
||||
## proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} =
|
||||
## echo("Downloaded ", progress, " of ", total)
|
||||
## echo("Current rate: ", speed div 1000, "kb/s")
|
||||
## client.onProgressChanged = onProgressChanged
|
||||
## discard waitFor client.getContent("http://speedtest-ams2.digitalocean.com/100mb.test")
|
||||
##
|
||||
## proc asyncProc() {.async.} =
|
||||
## var client = newAsyncHttpClient()
|
||||
## client.onProgressChanged = onProgressChanged
|
||||
## 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``.
|
||||
##
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue