![]() ![]() This is the path users will navigate to in order to access the chat. Next, we’re going to create a route ( /chat) for our new chat page by editing the router file at lib/liveview_chat_web/router.ex. If everything goes right, you should be able to run your Phoenix server with mix phx.server and view the default homepage by navigating to in your browser. If you’re planning to build this demo project into something bigger, you may wish to include Ecto functionality by omitting the -no-ecto flag.įollow the steps from mix to get your project created and the dependencies installed. ![]() We’re doing so in this example for simplicity, and so that we don’t need to worry about setting up a database. The -no-ecto flag here means that we don’t want to include the Ecto datamapper library in our project. Assuming your environment is properly configured, you can generate a full Phoenix project directory with:mix phx.new liveview_chat -no-ecto Once you’ve got Elixir & Phoenix installed, the first thing we’re going to do is create the project. ![]() Let’s get started! Step 1 - Project Setup If you haven’t worked with this stack before, this is the perfect opportunity to try it out and see the power for yourself. I’ve written previously about LiveView and why I think it’s such an amazing tool. That means you can build highly interactive “single page”-style webapps without writing a line of JavaScript. The Phoenix web framework takes advantage of these features and enables LiveView for highly interactive server-rendered content. Elixir is so amazing in part because it’s built on the Erlang Virtual Machine, which means it supports highly available and highly concurrent applications by nature. Prerequisites - What is Phoenix? What is LiveView?īefore starting on this project, you’ll need to follow the instructions to install both Elixir and Phoenix.īriefly, Phoenix is a sophisticated web framework written in the amazing Elixir language. Some specific things we won’t address (but are simple additions for those who want to learn more) are user authentication and management chat message persistence and support for multiple channels with a lobby. To keep this example as minimal as possible, we’re going to cut some corners to focus on the core use case. Finally, the LiveView processes will render the messages back to each connected user. Our basic strategy in this project will be to use a persistent Phoenix LiveView process for each user who connects to the server, and then use Phoenix’s built-in PubSub (“publish/subscribe”) functionality to broadcast messages to all of the connected processes. ![]() That includes all the code for both the frontend and the backend (spoiler alert: they’re kind of the same thing). If you haven’t experienced the awesome power of LiveView in the Phoenix framework, strap in: we’re going to build a real-time, high-performance chat system with fewer than 50 lines of code. 6 min read Photo by Marek Piwnicki / Unsplash.Ability to create custom Livebook controls using Kino.JS.Live and Kino.– Brooklin Myers working on a Livebook "carousel" feature.– New "Admonition Blocks" feature added to ExDoc.– Improved the JIT’s support for tools perf and gdb.– erlang:float_to_binary/2 has new short option.– Speed improvements for compiling on M1 chips.– Erlang/OTP 25.0-rc1, (Release Candidate 1).We also talk about another goal of his, to improve working with forms in LiveView! While still early, it can be a great tool for teams. It’s called PhoenixProfiler and it ties into Telemetry events for data. He is working on a development toolbar that is rendered on your pages and helps profile performance, expose route info, show crash info and more. We talk with Michael Crumm, the primary author of the Phoenix Live Dashboard, about a new project of his. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |