1. 12

  2. 5

    Something a bit less obvious–you can write an async recursive loop with futures if you’re clever, but your future implementation needs to have built in support for it. In scala (using Twitter futures, although Scala futures support this too as of 2.10.3)

    def loop(): Future[Unit] = Future.sleep(5.seconds).onSuccess { _ =>

    This is quite tricky–the originally returned future is never satisfied, and this keeps on telescoping in forever, so if you’re not smart about this you’ll end up with a big space leak. If you’re curious, the scala promise implementation has a good explanation of how this works.

    1. 3

      For a more monady promise:


      1. 2

        Monadic burritos strike again.