I’m up to page 15 and suddenly I’m being told to add code to dazzle_live.ex, which does not exist in the project at all. I can only assume I’m supposed to be adding it to ticker_live.ex?
Did the filename change part way through writing this, and not all occurrences were updated perhaps?
There was an earlier occurrence which was confusing as well. On page 10:
“Open up the lib/dazzle_web/live/ticker_live.ex file”
Nobody has talked about even creating the file yet, and I’m being asked to open it?
Maybe my example doing this first chapter it could help you, look at in here:
Let me try to help…
the mount functions its call the first time when you open the page and this function sets a timer to send a message called :tick for self() with 250 milliseconds.
The socket keeps the state when the first time you access the initial state is count equal to 0 in my code.
and if you see the handle_info its a function to handle with info about the process in your system, and in the mount function you sent a message, and the handle_info functions have a pattern matching, look:
def handle_info(:tick, socket) do
{:noreply, inc(socket)}
end
These functions doing a match with :tick and remember when I said the socket it’s your state? so we pass the socket for another function called inc.
def inc(socket) do
assign(socket, count: socket.assigns.count + 1)
end
And the inc function you assign you to state and increment +1 in your count every 2 seconds and a half and update your state.
The handle_info function is :noreply ? because we update your state/page and you don’t necessarily respond to the client who ask to update more like async way.
Yeah, I figured it must have been ticker_live I was supposed to add it to, I was just pointing out that the book was saying to add code to a file that doesn’t exist.