Course 'Intermediate Scala'
$495usd

The "Future Callbacks" lecture is not free and you are not enrolled in the course, or you are not logged in. Information about the lecture follows. Click on the About the Course and Course Outline tabs above to learn more about the course. You can enroll by clicking on the button on the upper right of this page.

Lecture Contents

Callback Methods

onSuccess

onFailure

onComplete

andThen

Callbacks Trigger Immediately for Promises Created With Values

Callbacks Trigger After Promises Complete

Partial Functions Can Have Many Cases

Chaining andThen Callbacks

Completing with Failure

Creating a Future Directly

Exercise – Test Your Understanding

Solution and Takeway

References: Lecture MultiThreading
Lecture Higher-Order Functions
Lecture Futures & Promises
Lecture Getting Results from Futures & Signaling with Promises
Lecture Future Combinators
Lecture Partial Functions
Lecture Working With Collections of Futures
Lecture Scala Traits
Referenced by: Lecture Futures & Promises
Lecture Getting Results from Futures & Signaling with Promises
Lecture Future Combinators

Abstract

This lecture discusses how callbacks work for Scala Futures, including completing Futures successfully and with failure. The transcript has been updated for Scala 2.12 – happily, the advice given previously was prescient so the recommendations given in this lecture have not changed.

Revision History

Date Changes
2016-03-09 Updated to Scala 2.12 and republished video
2015-10-21 Updated transcript for Scala v2.12-M3
2015-03-10 Republished video
2015-03-08 Added method signatures to the Callback Methods section and enhanced the discussion
2015-01-07 Published video
2015-01-01 Moved the sample code to the multi/futures package
2014-10-01 Hived Getting Results from Futures & Signaling with Promises from this lecture, renamed this lecture from Future Callbacks, Results & Signaling with Promises
2014-09-22 Hived this lecture from Futures & Promises. Published transcript.
You will feel right at home learning Apache Spark, Akka or Play Framework 2 for Scala after taking this course


This Intermediate Scala course builds on the Introduction to Scala course. Many concepts and techniques are introduced, with lots of working code examples and exercises, including functional programming, implicits, process control, I/O, collections, pattern matching, combinators, partial functions, application configuration techniques, memoization, and multithreading (including parallel collections, Futures, Promises and Akka Actors). You can see a detailed outline from the Outline tab of this web page. We guarantee that taking this course will make you work hard; and as a result students gain a lot of practical, hands-on experience with Scala. The concepts taught allow you to feel comfortable with the code that you will find in Apache Spark and Play Framework 2 for Scala projects, and motivational Spark and Play examples are provided in the course.

As with the Introduction to Scala course, this course is based on code samples that can be pasted into the Scala REPL, and that code is also provided in the the courseNotes directory. The course consists of 10 hours of video, over 450 pages of lecture notes (if printed as an O'Reilly-sized book), more than six-dozen sample programs and about a dozen exercises.

We suggest that students take this course before moving on to Introduction to Play Framework for Scala, Apache Spark or working on other industrial-strength Scala projects.

In addition to self-paced online learning, Micronautics Research (the company that operates ScalaCourses.com) offers on-site and remote delivery for this course. Our instructors use videoconferencing to provide office hours so students can interact directly. Please contact us for further details.

The overview video on the front page of this web site discusses how ScalaCourses.com works.

Prerequisites

Introduction to Scala or equivalent.

 

Date Lecture Changes
2017-06-16 Parametric Types Added section Parameters with Abstract Classes vs Traits to transcript.
2017-06-05 Introduction to Actors Replaced ActorSystem.shutdown with ActorSystem.terminate
2017-06-05 Akka ActorSystem Replaced ActorSystem.shutdown with ActorSystem.terminate, and added code examples
2017-06-05 Process Control Added another more detail for Process.apply
2017-02-24 HOCON Configuration Modified the list of HOCON wrappers at the end of the lecture to only include actively supported projects
2017-02-21 Scala I/O Added a code example for Scala 2.12's new io.Source.fromResource to the transcript.
2017-02-09 Parametric Variance and Bounds Updated to use new Scala Type Hierarchy diagram and republished video
2016-12-05 All Updated code examples to Scala 2.12.1
2016-11-09 All Updated code examples to Scala 2.12
2016-10-29 Parametric Types Updated video to match transcript
2016-10-28 Introduction to Collections Reworked transcript and video
2016-10-26 Implicit Conversions Updated video to match transcript
2016-10-26 Parametric Variance and Bounds Updated video to match transcript
2016-10-25 Structural Types Updated video to match transcript
2016-10-24 Immutable Collections Reworked transcript, added several sections, republished video
2016-10-24 For-Loops and For-Comprehensions Examples Added Short-Circuiting and Short-Circuiting a for-comprehension sections
2016-10-24 For-Loops and For-Comprehensions Added Short Circuiting section
2016-10-15 Implicit Conversions Added another example to the Coercion by Implicit Conversions section
2016-10-15 For-Loops and For-Comprehensions Examples Rewrote Either is Not Right-Biased section for Scala 2.12 and renamed it Either is Right-Biased With Scala 2.12.
2016-10-13 HOCON Configuration Reworked lecture and updated video
2016-10-11 Scala I/O Reworked entire lecture and republished video
2016-10-09 Getting Results from Futures & Signaling with Promises Reworked transcript and video so it flows better
2016-10-08 Combinators Updated video to match transcript
2016-10-08 MultiThreading Added additional information on task switch overhead and updated video to match transcript
2016-09-29 Introduction to Collections Added reference to Benchmarking Scala Collections article
2016-09-14 MultiThreading Added graphic showing 'Not all CPU operations are created equal'
2016-08-28 Combinators Added section Use Intermediate Variables and Declare Their Types to transcript
2016-08-27 HOCON Configuration Rearranged material and added Arrays of Properties section to transcript
2016-08-01 HOCON Configuration Added a discussion of the resolve method
2016-07-24 Implicit Values Added SLS 7.1 section to transcript
2016-06-28 MultiThreading Mentioned scala.concurrent.forkjoin.ForkJoinPool was deprecated by Scala 2.12
2016-03-30 Implicit Classes Republished video
2016-03-11 Parametric Types Reworked transcript and published a new video
2016-03-11 Implicit Classes Added reference to the Parametric Traits as Rich Interfaces of the Parametric Types lecture
2016-03-10 For-Loops and For-Comprehensions Added Extraction section to transcript
2016-03-09 Future Callbacks Updated to Scala 2.12 and republished video
2016-03-02 Higher-Order Functions Updated Exercise – Using the Predefined WrappedString Implicit Class to Scala 2.11.8 and republished video
2016-03-02 Combinators Heavily edited lecture and republished video
2016-03-02 For-Loops and For-Comprehensions Completely rewrote lecture transcript and republished video
2016-01-31 For-Loops and For-Comprehensions Added Desugaring with Quasiquotes section.
2015-12-29 Combinators Improved flatMap section in transcript
2015-12-10 HOCON Configuration Added Generating JSON section to transcript.
2015-12-01 MultiThreading Added section ThreadLocal vs. Fork-Join to transcript
2015-11-19 Implicit Conversions Updated video with Methods as Implicit Values section
2015-11-18 Immutable Collections Added a discussion of complexity for immutable.List operations
2015-11-07 MultiThreading Updated most of the links to Java, Akka and Scala docs
2015-10-21 Future Callbacks Updated for Scala v2.12-M3
2015-10-12 Implicit Values Updated transcript and republished video
2015-10-11 Implicit Conversions Added Methods as Implicit Values section
2015-10-10 Parametric Types Added Scala 2.12 @implicitAmbiguous section
2015-09-23 Partial Functions Added lift and unlift sections and reworked entire video.
2015-09-20 Partially Applied Functions Rewrote the last section and broke it into two sections: AntiPatterns: Eager Evaluation and Closing Over External State and Pattern: Designing Layered Software, republished video with many other improvements.
2015-09-17 Using Partially Applied Functions Numerous changes to transcript and republished video
2015-08-11 Introduction to Collections Added UML Diagrams of Scala 2.11 Collection Classes
2015-08-06 Partial Functions Added the AndThenTry exercise and More Than Two Cases to Handle Try section to the transcript, and republished video. Also added two portions of code from this lecture to the scalacourses-utils project.
2015-07-11 Parametric Variance and Bounds Added new exercise: Create a Failure-Proof init Method
2015-07-11 Immutable Collections Improved the failure-proof init example
2015-07-08 Combinators Added exercise Exercise - HTTP URL-Form Encoded Parameters
2015-06-15 For-Loops and For-Comprehensions Examples Added Either is Not Right-Biased section to transcript.
2015-05-24 Partially Applied Functions Enhanced the Partially Applying the apply Method section in the transcript
2015-04-22 Implicit Values Added section Using implicitly To Resolve Implicit Parameters to the transcript
2015-03-11 Pattern Matching on Collections Expanded transcript and published video
2015-03-10 Pattern Matching on Sequences Added new exercise Extract File Type from Path to end of lecture
2015-03-10 Future Callbacks Republished video
2015-03-08 Future Callbacks Added method signatures to the Callback Methods section, and enhanced the discussion
2015-03-06 Working With Collections of Futures Renamed repository from futurePerfect to scalacourses-utils.
2015-03-05 Memoization in Depth Published first version of transcript and code examples
2015-02-23 Implicit Classes Added Yet Another Example and Comprehensive Example
2015-02-23 Implicit Classes Added new section to the transcript: Where to Put Implicit Definitions?
2015-02-20 Implicit Values Added This Lecture Introduces Two Concepts section to the transcript
2015-02-11 Partially Applied Functions Added Revisiting the Handmade unless Construct section to the transcript
2015-02-03 Introduction to Actors Published video
2015-01-30 Akka ActorSystem Published video
2015-01-29 Future Bad Habits and Exercise Published video
2015-01-27 Working With Collections of Futures Published video
2015-01-20 Sorting and Ordered Collections Video & transcript greatly enhanced; 50% longer
2015-01-14 Partial Functions Added Trying Harder Exercise
2015-01-11 Future Combinators Published video
2015-01-08 For-comprehensions With Futures Published video
2015-01-07 Future Callbacks Published video
2015-01-03 Immutable Collections Added About the foreach section for Iterator.continually example
2015-01-03 Getting Results from Futures & Signaling with Promises Published video
2015-01-01 Parametric Types Enhanced the transcript for the Parametric Traits as Rich Interfaces example
2015-01-01 Introduction to Actors Moved the sample code to the multi package
2015-01-01 Akka ActorSystem Moved the sample code to the multi package
2015-01-01 Future Bad Habits and Exercises Moved the sample code to the multi/futures package
2015-01-01 Working With Collections of Futures Moved the sample code to the multi/futures package
2015-01-01 Future Combinators Moved the sample code to the multi/futures package
2015-01-01 Future For-comprehensions Moved the sample code to the multi/futures package
2015-01-01 Getting Results from Futures & Signaling with Promises Moved the sample code to the multi/futures package
2015-01-01 Future Callbacks Moved the sample code to the multi/futures package
2015-01-01 Futures & Promises Moved the sample code to the multi/futures package
2015-01-01 Parallel Collections Moved the sample code to the multi package
2015-01-01 Higher-Order Functions Corrected video and transcript for the Timing a Task section
2014-11-21 Implicit Values Added Strongly Typed Method Parameters section to Value Classes discussion
2014-11-19   Updated courseNotes project to SBT 0.13.7
2014-11-13 Futures & Promises Published video
2014-11-12 Parallel Collections Published video
2014-11-04 Parametric Variance and Bounds Published video
2014-11-01   Updated sample code to Scala 2.11.4
2014-10-19 Partial Functions Published video
2014-10-16 MultiThreading Published video
2014-10-11   Updated sample code to Scala 2.11.3
2014-10-07 Working With Collections of Futures Added Processing Futures As They Complete and Canceling Futures sections
2014-10-07 For-Loops and For-Comprehensions Added Can't Mix Monads section to the transcript.
2014-10-01 Partial Functions Updated lecture for recording
2014-10-01 Working With Collections of Futures Hived from Combinators and Collections, renamed that lecture to Combinators
2014-10-01 Getting Results from Futures & Signaling with Promises Hived from the Future Callbacks, Results & Signaling with Promises lecture, and renamed that lecture to Future Callbacks
2014-09-30 Combinators Added short section to the transcript discussing the identity transformation
2014-09-29 MultiThreading Added Runtime ExecutionContext Selector section to transcript.
2014-09-22 Future Bad Habits and Exercise Hived this lecture from Futures & Promises
2014-09-22 Future For-comprehensions, Combinators, Collections & Failure Hived this lecture from Futures & Promises
2014-09-22 Future Callbacks, Results & Signaling with Promises Hived this lecture from Futures & Promises
2014-09-22 Futures & Promises Updated material and split into four lectures
2014-09-18 Sorting and Ordered Collections Added Enumeration Value Sets section
2014-09-18 Using Partially Applied Functions Fixed compile error in courseNotes/src/main/scala/solutions/DBOps.scala
2014-09-16 Immutable Collections Updated transcript: Added discussions on type hints, expanded the discussion of Nil into an entire section, and provided guidelines on using headOption, tailOption, lastOption and drop instead of head, tail, last and init.
2014-09-12 Using Partially Applied Functions Improved the Wrapping Database Operations With the Loan Pattern Exercise
2014-08-30 Introduction to Collections Recorded new 5 minute video section for Custom String Interpolation section
2014-08-24 Introduction to Collections Added Defining Custom String Interpolation to Access a Map section to transcript
2014-08-15 Combinators Added Writing for Clarity section
2014-08-11 Using Partially Applied Functions Published video
2014-08-09 Partially Applied Functions Published video
2014-08-09 Using Partially Applied Functions Hived this lecture from the Partially Applied Functions lecture
2014-08-04 Structural Types Published video
2014-07-19 Combinators Updated video, now includes an 8 minute long section on Idioms
2014-07-15 Combinators Added Idioms section to transcript, addressing writing style.
2014-07-12 Futures Added a comprehensive example (Cross-Context Signaling with Promises) showing how to use a Promise to clean up Java callbacks.
2014-07-05 Process Control Added an example of Scala process control calling a command with arguments and passing an environment variable, and republished the video.
2014-06-22   Updated brew install incantation in this page.
2014-06-22 Parametric Types Added section and code examples for scoped and shadowed type parameters.
2014-06-21 Typesafe Config Exercise and Extended Example Published video.
2014-06-20 Typesafe Config Published video.
2014-06-11 For-Loops and For-Comprehensions Examples Added For-Comprehension of Trys example and republished video.
2014-06-13   Updated courseNotes and solutions SBT projects to Scala 2.11.1.
2014-06-12 Extended Example of For-Comprehensions Published video.
2014-06-11 For-Loops and For-Comprehensions Examples Published video.
2014-06-11 For-Loops and For-Comprehensions Added map/orElse idiom to transcript and republished video.
2014-06-11 Introduction to Collections Added Map.getOrElse to transcript.
2014-04-13 For-Loops and For-Comprehensions
For-Loops and For-Comprehensions Examples
Extended Example of For-Comprehensions
Updated transcript, released new video, moved examples and quizzes into 2 new lectures, which follow.
2014-06-04 Combinators Updated video.
2014-04-18 Sorting and Ordered Collections Published video.
2014-03-31   Updated courseNotes project to Scala 2.10.4.
2014-04-15 Introduction to Collections
Immutable Collections
Mutable Collections
Collection Converters
Overly long collections lecture split into smaller, more focused lectures.
2014-03-28   Updated Course Notes PDF provided in git repository.
2014-03-28 Parallel Collections Added solution for exercise.
2014-03-21 Typesafe Config Wrote transcript.
2013-09-18 Implicit Values
Implicit Conversions
Implicit Classes
Split long lecture into more focused, smaller lectures.
2013-09-15 Scala I/O Wrote transcript.
2013-03-14 Sorting and Ordered Collections Wrote transcript.
2014-03-12 Combinators Added discussion of monads.
2013-10-21 Partially Applied Functions Wrote transcript.
2013-09-14 Concurrency
Futures
Introduction to Actors
Updated transcripts and sample code.
2013-09-10   Early access program started.
2012-12-14   Initial course setup.
Price: $495usd
Instructor(s): ,