Retrieve a Task’s Results
Learn to use Task.async, which has the property to return a struct containing the executed task’s result.
We'll cover the following...
The Task.async/1
task
To retrieve the result of a function, we use Task.async/1
. It returns a %Task{}
struct which we can assign to a variable for later use. We can give it a try in IEx like this:
This is the executable command:
Press + to interact
task = Task.async(fn -> Sender.send_email("hello@world.com") end)
Here is the output we get:
...