Last active
July 7, 2016 19:20
-
-
Save RichardHightower/68c45f7ca1334cf4fdbe6e50316b2520 to your computer and use it in GitHub Desktop.
Make two async calls and not returning until both come back or fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun removeArtistFromSystem(artistId: Long): Promise<Boolean> { | |
return Promises.invokablePromise { promise -> | |
val saveSystemDataPromise = Promises.promiseBoolean() | |
.catchError { e -> logger.info("removeArtistFromSystem:: unable to save system data for $artistId", e) } | |
val removeArtistFromSystemPromise = Promises.promiseBoolean() | |
.catchError { e -> logger.info("removeArtistFromSystem:: unable to remove $artistId from repo", e) } | |
Promises.all(saveSystemDataPromise, removeArtistFromSystemPromise) | |
.then { | |
promise.resolve(true) | |
} | |
.catchError { e -> | |
promise.reject(e) | |
} | |
systemData.artistIds.remove(artistId) | |
saveSystemData(saveSystemDataPromise) | |
artistRepo.removeArtistFromSystem(artistId).invokeWithPromise(removeArtistFromSystemPromise) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment