Last active
March 14, 2018 21:39
-
-
Save desmondmonster/ea8b1eed218264f3def7822a8d42a04b to your computer and use it in GitHub Desktop.
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
defmodule App.UserService do | |
def create_user(params) do | |
%App.User{} | |
|> App.User.changeset(params) | |
|> App.Repo.insert() | |
|> case do | |
{:ok, user} -> | |
Task.start(fn -> send_email_to_user(user) end) # 🎉 | |
{:ok, user} | |
{:error, changeset} -> | |
{:error, changeset} | |
end | |
end | |
defp send_email_to_user(user) do | |
# send the email | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment