Last active
March 22, 2017 18:56
-
-
Save a-type/deee692a10fe480791dbc44d807e7f60 to your computer and use it in GitHub Desktop.
Example Code for Presentation
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
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 |
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
Repo.get(User, id) | |
|> &increment_login_attempts | |
|> &Repo.update |
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
User user = UserDao.findById(id); | |
user.incrementLoginAttempts(); | |
User updatedUser = UserDao.update(user); | |
System.out.println(user == updatedUser); // who knows? |
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
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