Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Scala Reactive Programming

You're reading from   Scala Reactive Programming Build scalable, functional reactive microservices with Akka, Play, and Lagom

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781787288645
Length 552 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Rambabu Posa Rambabu Posa
Author Profile Icon Rambabu Posa
Rambabu Posa
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Getting Started with Reactive and Functional Programming FREE CHAPTER 2. Functional Scala 3. Asynchronous Programming with Scala 4. Building Reactive Applications with Akka 5. Adding Reactiveness with RxScala 6. Extending Applications with Play 7. Working with Reactive Streams 8. Integrating Akka Streams to Play Application 9. Reactive Microservices with Lagom 10. Testing Reactive Microservices 11. Managing Microservices in ConductR 12. Reactive Design Patterns and Best Practices 13. Scala Plugin for IntelliJ IDEA 14. Installing Robomongo 15. Other Books You May Enjoy

The Scala Future API in the Akka Toolkit

Both the Akka Toolkit and the Play Framework source code use Scala Futures extensively. The Akka Streams API also uses the Scala Future in all places.

Let's look at some Akka Streams source code examples here which are using the Scala Future API:

In the Akka Toolkit, the ask pattern returns a Future[Any], shown as follows:

def ask (actorRef: ActorRef, message: Any)(implicit timeout: Timeout): Future[Any]

Observe the following Akka Streams API:

val futureResult: Future[Seq[String]] = Source(in).runWith(Sink.seq)

Here, the Souce.runWith[T]() function returns its results as Future[T]. Not only this function, but most of the Akka Streams API uses Scala Futures extensively. We use the Scala Future API to write some unit tests, too.

Now you get what is the importance of this Scala Future API. Please experiment with some more examples to...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image