tcallbacks.nim 346 B

12345678910111213141516171819202122
  1. discard """
  2. exitcode: 0
  3. output: '''
  4. 1
  5. 2
  6. 3
  7. 5
  8. '''
  9. """
  10. import asyncfutures
  11. let f1: Future[int] = newFuture[int]()
  12. f1.addCallback(proc() = echo 1)
  13. f1.addCallback(proc() = echo 2)
  14. f1.addCallback(proc() = echo 3)
  15. f1.complete(10)
  16. let f2: Future[int] = newFuture[int]()
  17. f2.addCallback(proc() = echo 4)
  18. f2.callback = proc() = echo 5
  19. f2.complete(10)