|
|
|
|
|
by dionian
199 days ago
|
|
```
// The kind of code that made me fall out of love
implicit def enrichedFuture[A](f: Future[A])(implicit ec: ExecutionContext): EnrichedFuture[A] =
new EnrichedFuture(f)
class EnrichedFuture[A](f: Future[A])(implicit ec: ExecutionContext) {
def |>[B](g: A => Future[B]): Future[B] = f.flatMap(g)
def <*>[B](fb: Future[B]): Future[(A, B)] = for { a <- f; b <- fb } yield (a, b)
}
``` it's really not all THAT bad... and if you use a library, like monix or zio, you dont have to deal with Future. but i get it. |
|