Slide 40
Slide 40 text
Leverage Concurrency
(but abstract away its complexity)
Fully asynchronous API - Clients can’t block
def video1Call = api.getVideos(api.getUser(), 123456, 7891234);
def video2Call = api.getVideos(api.getUser(), 6789543);
// higher-order functions used to compose asynchronous calls together
wx.merge(video1Call, video2Call).toList().subscribe([
onNext: {
listOfVideos ->
for(video in listOfVideos) {
response.getWriter().println("video: " + video.id + " " + video.title);
}
},
onError: {
exception ->
response.setStatus(500);
response.getWriter().println("Error: " + exception.getMessage());
}
])
Service calls are
all asynchronous
Functional
programming
with higher-order
functions
40