![]() Another example would be manipulating a map, accessing geolocation resources, BlueTooth, wifi among others only with the browser, and hooks will help you in these processes. The most common example is to listen to the page and wait that when you reach the end, load new elements, Javascript gives you this very easy resource, the hook will help you send it to your server. But the biggest difference is that on a day-to-day basis Liveview takes care of almost all this work, the Hook is a way where you need to manipulate the DOM for something very specific that using LiveView would be almost impossible. ![]() The main difference is that hooks are a way to send and receive data from the frontend/backend to the browser using a javascript syntax with Elixir, it looks a lot like a LiveView page or nothing new. What is the Difference between Hooks and Liveview in everyday life? The hook is nothing more than a "hook", where you can send events to the server and vice versa. Want to learn more about elixir on a Telegram channel? _ps: You can follow the article with VIDEO I am Gustavo and today's theme is: Getting Started Using Hooks with Phoenix and Liveview This is from scratch until your first wave as an elixir developer Here we discuss strategies and tips for your Elixir learning journey. Now when the user navigations across LiveViews, the live layout will reactively update as the URL changes, and our tabs will be highlighted appropriately.Hello #devElixir!!! Welcome to #FullStackElxpro Likewise, we set the active tab to :settings if routed to the SettingsLive LiveView. When viewing a user's profile, we only set the active tab to :profile if the current user is viewing their own profile. Within set_active_tab/3, we implemented logic to set the based on the params, LiveView module, and live action from the router. We named our hook :active_tab and attached it to the handle_params stage of the socket life cycle and we passed our set_active_tab/3 function to be invoked for this stage. The most important part of this callback can be seen in line 7, where we call attach_hook/4. Live_session :authenticated, on_mount: end endįirst, in line 4 we are defining the on_mount callback that will be used as :default if no other option is sent in the invocation of the hook within router.ex Defining the Sidebar Markupįirst we'll define the markup of the application sidebar within our live layout in, in this way it will be part of the life cycle of our LiveView components. Today I'll share with you a recipe on how we can handle navigation within our Liveview applications and how we can offer the user a navigation bar that shows the active tab in which the user is located. For this we use navigation components such as navbars or sidebars and we as developers are faced with the challenge of showing the user in each interaction with the website the place where they are in a clear and intuitive way. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |