March 2020
Intermediate to advanced
392 pages
10h 10m
English
If you have dealt with network connections in the past, you will be familiar with the concept. There are two ways of looking at requests: synchronously and asynchronously.
Synchronously means you send a request (for example, to a server) and your code will wait for a response before it continues. An example would look like this. This is the actual code from a Vapor 2 project:
let user = User() // User is a model that is connected to a databaseuser.id = 2 // set some attributetry user.save() // saves this model to the database print("saved") // this line is called after we saved
The last line is only called after the user is saved; the whole program waits for the saving process to be finished. In contrast to the synchronous ...
Read now
Unlock full access