Last active
June 6, 2020 08:32
-
-
Save tslim/bbb9dff580fd2e71def02f368afc19de to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def mount(_params, _session, socket) do | |
{:ok, fetch_users(socket)} | |
end | |
def handle_event("delete", %{"id" => id}, socket) do | |
user = Accounts.get_user!(id) | |
{:ok, _} = Accounts.delete_user(user) | |
{:noreply, fetch_users(socket)} | |
end | |
defp fetch_users(socket) do | |
assign(socket, :users, Accounts.list_users()) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment