Skip to content

Instantly share code, notes, and snippets.

@keehun
Last active April 17, 2019 22:25
Show Gist options
  • Save keehun/df56304f2c2dca2cac37e86619405e55 to your computer and use it in GitHub Desktop.
Save keehun/df56304f2c2dca2cac37e86619405e55 to your computer and use it in GitHub Desktop.
async function getMoviePackageFor(movie_id) {
/// Get the URLs of the movie and subtitle file in parallel
const movie_url = await MovieDatabase.getURLFor(movie_id)
const subtitle_url = await SubtitleDatabase.getURLFor(movie_id)
/*
By the way, if you want those two async actions to run in
parallel, you can do this:
const [movie_url, subtitle_url] = await Promise.all([
MovieDatabase.getURLFor(movie_id),
SubtitleDatabase.getURLFor(movie_id),
])
*/
const movie_file = await DownloadTool.download(movie_url)
const subtitle_file = await DownloadTool.download(subtitle_url)
return [movie_file, subtitle_file]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment