July 2021
Intermediate to advanced
176 pages
4h 14m
English
Before jumping into the Task module, let’s see how things work at the moment. Let’s call the send_email/1 function from IEx, and pass a fictional email address as an argument. Don’t forget to run the recompile() command first if you’ve been running IEx already:
| | iex> recompile() |
| | Compiling 1 file (.ex) |
| | :ok |
| | |
| | iex> Sender.send_email("hello@world.com") |
| | Email to hello@world.com sent |
| | {:ok, "email_sent"} |
Did you notice the delay? We had to wait three seconds until we saw the printed output and result. In fact, even the iex> prompt was not showing. Let’s add another function, notify_all/1:
| | def notify_all(emails) do |
| | Enum.each(emails, &send_email/1) |
| | end |
The notify_all/1 ...
Read now
Unlock full access