title: Asynchronous Iterable over remote data
body: <p>There is some data that I have pulled from a remote API, for which I use a Future-style interface. The data is structured as a linked-list. A relevant example data container is shown below.</p>
  
  <pre><code>case class Data(information: Int) {
      def hasNext: Boolean = ??? // Implemented
      def next: Future[Data] = ??? // Implemented
  }
  </code></pre>
  
  <p>Now I'm interested in adding some functionality to the data class, such as <code>map</code>, <code>foreach</code>, <code>reduce</code>, etc. To do so I want to implement some form of <code>IterableLike</code> such that it inherets these methods.
  Given below is the trait <code>Data</code> may extend, such that it gets this property.</p>
  
  <pre><code>trait AsyncIterable[+T]
      extends IterableLike[Future[T], AsyncIterable[T]]
  {
      def hasNext : Boolean
      def next : Future[T]
  
      // How to implement?
      override def iterator: Iterator[Future[T]] = ???
      override protected[this] def newBuilder: mutable.Builder[Future[T], AsyncIterable[T]] = ???
      override def seq: TraversableOnce[Future[T]] = ???
  }
  </code></pre>
  
  <p>It should be a non-blocking implementation, which when acted on, starts requesting the next data from the remote data source.
  It is then possible to do cool stuff such as</p>
  
  <pre><code>case class Data(information: Int) extends AsyncIterable[Data]
  val data = Data(1) // And more, of course
  // Asynchronously print all the information.
  data.foreach(data =&gt; println(data.information))
  </code></pre>
  
  <p>It is also acceptable for the interface to be different. But the result should in some way represent asynchronous iteration over the collection. Preferably in a way that is familiar to developers, as it will be part of an (open source) library.</p>