@@ -7,8 +7,8 @@ defmodule LiveDebuggerDev.LiveViews.Main do
77 socket =
88 socket
99 |> assign ( counter: 0 )
10- |> assign ( slow_counter : 0 )
11- |> assign ( very_slow_counter : 0 )
10+ |> assign ( counter_slow : 0 )
11+ |> assign ( counter_very_slow : 0 )
1212 |> assign ( datetime: nil )
1313 |> assign ( name: random_name ( ) )
1414 |> assign ( single_element_list: [ % Phoenix.LiveComponent.CID { cid: 1 } ] )
@@ -22,7 +22,7 @@ defmodule LiveDebuggerDev.LiveViews.Main do
2222 < . box title = "Main [LiveView] " color = "blue " >
2323 < div class = "flex flex-col gap-2 " >
2424 < div class = "flex items-center gap-2 " >
25- < . button phx-click = "increment " color = "blue " >
25+ < . button id = " increment-button " phx-click = "increment " color = "blue " >
2626 Increment
2727 </ . button >
2828 < span class = "text-xl " > <%= @ counter %> </ span >
@@ -31,16 +31,16 @@ defmodule LiveDebuggerDev.LiveViews.Main do
3131 < . button phx-click = "slow-increment " color = "blue " >
3232 Slow Increment
3333 </ . button >
34- < span class = "text-xl " > <%= @ slow_counter %> </ span >
34+ < span class = "text-xl " > <%= @ counter_slow %> </ span >
3535 </ div >
3636 < div class = "flex items-center gap-2 " >
3737 < . button phx-click = "very-slow-increment " color = "blue " >
3838 Very Slow Increment
3939 </ . button >
40- < span class = "text-xl " > <%= @ very_slow_counter %> </ span >
40+ < span class = "text-xl " > <%= @ counter_very_slow %> </ span >
4141 </ div >
4242 < div class = "flex items-center gap-1 " >
43- < . button phx-click = "change_name " color = "red " >
43+ < . button id = " update-button " phx-click = "change_name " color = "red " >
4444 Update
4545 </ . button >
4646 < div >
@@ -82,17 +82,17 @@ defmodule LiveDebuggerDev.LiveViews.Main do
8282 end
8383
8484 def handle_event ( "increment" , _ , socket ) do
85- { :noreply , assign ( socket , :counter , socket . assigns . counter + 1 ) }
85+ { :noreply , update ( socket , :counter , & ( & 1 + 1 ) ) }
8686 end
8787
8888 def handle_event ( "slow-increment" , _ , socket ) do
8989 Process . sleep ( 400 )
90- { :noreply , assign ( socket , :slow_counter , socket . assigns . slow_counter + 1 ) }
90+ { :noreply , update ( socket , :counter_slow , & ( & 1 + 1 ) ) }
9191 end
9292
9393 def handle_event ( "very-slow-increment" , _ , socket ) do
9494 Process . sleep ( 2500 )
95- { :noreply , assign ( socket , :very_slow_counter , socket . assigns . very_slow_counter + 1 ) }
95+ { :noreply , update ( socket , :counter_very_slow , & ( & 1 + 1 ) ) }
9696 end
9797
9898 def handle_event ( "change_name" , _ , socket ) do
0 commit comments