Skip to content

Instantly share code, notes, and snippets.

@a-type
Last active March 22, 2017 18:56
Show Gist options
  • Save a-type/deee692a10fe480791dbc44d807e7f60 to your computer and use it in GitHub Desktop.
Save a-type/deee692a10fe480791dbc44d807e7f60 to your computer and use it in GitHub Desktop.
Example Code for Presentation
user = Repo.get(User, id)
updated_user =
user
|> &increment_login_attempts
|> &Repo.update
IO.inspect user # login_attempts = 0
IO.inspect updated_user # login_attempts = 1
Repo.get(User, id)
|> &increment_login_attempts
|> &Repo.update
User user = UserDao.findById(id);
user.incrementLoginAttempts();
User updatedUser = UserDao.update(user);
System.out.println(user == updatedUser); // who knows?
user = Repo.get(User, id)
# splits off asynchronously
Task.async(fn -> user |> &submit_data_to_tracker end)
result = delete_everything(user) # will never interfere with async process above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment