tnimcall_to_closure.nim 409 B

123456789101112131415161718
  1. import asyncdispatch
  2. proc defaultOnProgressChanged() = discard
  3. proc ask(x: proc()) = x()
  4. proc retrFile*(onProgressChanged: proc() {.nimcall.}): Future[void] =
  5. var retFuture = newFuture[void]("retrFile")
  6. iterator retrFileIter(): FutureBase {.closure.} =
  7. ask(onProgressChanged)
  8. complete(retFuture)
  9. var nameIterVar = retrFileIter
  10. return retFuture
  11. discard retrFile(defaultOnProgressChanged)