![]() ![]() ![]() The fingerprint is the most interesting part. The output of the render function is a struct. We’ve implemented our own to control how and when data is sent over the socket to the front-end. There is a default implementation in LiveView, so you don't have to implement your own. This is the first function that is called when the user makes a request. The first stop on our adventure train is mount/3. Point our browser to and start to look into how our application loads. Now let's add query parameters to the URL we will trace. Take your time to play around with the generated code and add a few users to the application. The three behaviors that LiveView passes through when a request is made: Now that we have the basic plumbing, let's start our server and explore this canyon twice. Create a new Phoenix LiveView mix Accounts User users name:string age:integer. We will limit the output here to the most relevant information, but you can follow along by generating a project.Ĭreate a new Phoenix LiveView project with mix phx.new live_view_lifecycle. The Output from dbg is verbose but helpful in understanding what is happening in our codebase. Recently, Kernel.dbg/2 was added to Elixir in version v1.14. Let's walk through the processes and arguments of the request and response lifecycle to see what we can learn about LiveView. The second pass occurs when the browser establishes the websocket connection that sends events and data back and forth between the application and the browser. It runs once to render static content for web crawlers, search engines, and other non-javascript-enabled clients. The LiveView request lifecycle runs twice when a connection is first made to your application. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |