Skip to content

Instantly share code, notes, and snippets.

@cipolleschi
Created June 6, 2020 13:37
Show Gist options
  • Select an option

  • Save cipolleschi/a014f04d4be07b4fa2c19ff8bce4f106 to your computer and use it in GitHub Desktop.

Select an option

Save cipolleschi/a014f04d4be07b4fa2c19ff8bce4f106 to your computer and use it in GitHub Desktop.
func prepareUserProfile() {
self.downloadUser() { user in
downloadUserMoviesAndFriendDataToPresentProfile(user: user)
}
}
func downloadUserMoviesAndFriendDataToPresentProfile(user: User) {
self.downloadFavouriteMovies(for: user) { movies in
downloadRatingsAndFriendsDataThenPresentProfile(user: user, movies: movies)
}
}
func downloadRatingsAndFriendsDataThenPresentProfile(user: User, movies: [Movie]) {
self.downloadRatings(for: movies) { ratings in
self.downloadFriendsDataAndPresentProfile(user: user, movies: movies, ratings: ratings)
}
}
func downloadFriendsDataAndPresentProfile(user: User, movies: [Movie], ratings: [Rating]) {
self.downloadFriends(for: users) { friends in
downloadFriendsMoviesAndPresentProfile(user: user, movies: movies, ratings: ratings, friend: friends)
}
}
func downloadFriendsMoviesAndPresentProfile(user: User, movies: [Movie], ratings: [Rating], friend: [User]) {
self.downloadMovies(for: friends] { friendMovies in
self.presentProfile(
for: user,
movies: movies,
ratings: ratings,
friends: friends,
friendMovies: friendMovies
)
}
}
// usage:
prepareUserProfile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment