In this video, take a look at suspending functions and how you can take advantage of them. Convert the work contained in a suspending lambda to a separate suspending function.
- [Instructor] Let's take a look at suspending functions…and how we can take advantage of them.…We're here inside of the CoroutinesAsync class…and we're going to add a new function…in order to test suspending functions.…Let's go ahead and copy what we have here…inside of our previous function, usingAsyncTwice,…and we'll just paste it at the bottom of the class file,…and let's rename this one to usingAsyncWithSuspendFunction.…
Then, instead of having two asynchronous coroutines…nested inside, let's just pair this down to one.…We'll delete what we have here in our second one,…and let's go ahead and get rid of this summation…and just change it to the result instead of the sum.…Now, we're back to having just one inner coroutine.…The next thing we want to do is extract out the code…inside of our async lambda to a new function.…Let's highlight the work that we have here…inside of our async lambda from line 71 to 73,…and we're just going to create a new function called ourWork.…
It's going to return an integer,…and then we'll paste that code that we have inside,…
- What Kotlin has to offer
- Working with lambdas
- Common Android extension functions
- Kotlin Android Extensions overview
- Making use of the Anko library
- Working with coroutines
- Nullability and collections
Skill Level Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
Developing AWS Lambda Functions with Kotlinwith Troy Miles1h 55m Intermediate
1. Kotlin Overview
2. Extension Functions and Properties
3. Incorporating Anko
4. Advanced Anko
5. Working with Collections
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.