Reader small image

You're reading from  Mastering play framework for scala

Product typeBook
Published inMay 2015
Reading LevelIntermediate
Publisher
ISBN-139781783983803
Edition1st Edition
Languages
Right arrow
Author (1)
Shiti Saxena
Shiti Saxena
author image
Shiti Saxena

Shiti Saxena is a software engineer with around 4 years of work experience. She is currently working with Imaginea (a business unit of Pramati). She has previously worked with Tata Consultancy Services Ltd. and Genpact. A true polyglot, she's had exposure to various languages, including Scala, JavaScript, Java, Python, Perl, and C. She likes to work with Play Scala and AngularJS. She blogs at http://eraoferrors.blogspot.in and maintains open source projects on GitHub. She loves to travel, is a movie buff, and likes to spend time playing her piano whenever she is not programming. She has authored Getting Started with SBT for Scala (https://www.packtpub.com/application-development/getting-started-sbt-scala).
Read more about Shiti Saxena

Right arrow

Asynchronous Actions


Suppose that we are at a food court and place an order to eat something at a kiosk, we are given a token and a bill. Later, when the order is ready, the kiosk flashes the token number, and upon noticing it, we collect the order.

This is similar to a request with an asynchronous response cycle, where the kiosk acts like the server, the order acts similar to a request, and the token as a promise, which gets resolved when the order is ready.

Most operations are better handled asynchronously. This is also mostly preferred since it does not block server resources until the operation is completed.

Play Action is a helper object, which extends the ActionBuilder trait. The apply method of the ActionBuilder trait implements the Action trait, which we saw earlier. Let's take a look at the relevant code from the ActionBuilder trait:

trait ActionBuilder[+R[_]] extends ActionFunction[Request, R] { 
  self => 

  final def apply[A](bodyParser: BodyParser[A])(block: R[A] => 
   ...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering play framework for scala
Published in: May 2015Publisher: ISBN-13: 9781783983803

Author (1)

author image
Shiti Saxena

Shiti Saxena is a software engineer with around 4 years of work experience. She is currently working with Imaginea (a business unit of Pramati). She has previously worked with Tata Consultancy Services Ltd. and Genpact. A true polyglot, she's had exposure to various languages, including Scala, JavaScript, Java, Python, Perl, and C. She likes to work with Play Scala and AngularJS. She blogs at http://eraoferrors.blogspot.in and maintains open source projects on GitHub. She loves to travel, is a movie buff, and likes to spend time playing her piano whenever she is not programming. She has authored Getting Started with SBT for Scala (https://www.packtpub.com/application-development/getting-started-sbt-scala).
Read more about Shiti Saxena