
- #Elixir phoenix components update#
- #Elixir phoenix components code#
It inherited its impressive concurrence characteristics from Elixir, which got it from Erlang, which got it thanks to the primitives of the BEAM virtual machine and the architectural patterns of OTP. Phoenix’s performance has surprisingly little to do with the framework itself. I wouldn’t go as far as to call it revolutionary, but it is definitely an intriguing attempt of bridging the gap between frontend and backend. Recent live view release is a whole new way of building dynamic apps. Primitives it gives you with channels, PubSub and Presence are just enough to avoid boilerplate without sacrificing flexibility. Phoenix is great for classical HTTP, but persistent communication is where it really shines. Use a specialized framework like Tornado, which (caution, personal opinion here) kind of an awkward choice for those parts of the web app that do not concern themselves with WebSockets. Integrate a 3rd party library into the framework, which means writing a pile of glue code, or When an app requires bi-directional communication between client and server, you usually either by default Phoenix comes with a huge pack of tools and utils (ORM, routing, test suit, HTML rendering, metrics dashboard (sic!)…), but in most cases, there’s a trivial way to swap them out or turn them off.
#Elixir phoenix components code#
When you get comfortable using a framework, you can probably read its code without too much trouble.
it does not hide its internal details in a “black box”, quite the opposite - it encourages you to understand internal conventions to write your own code in the same fashion. it builds upon Elixir’s functional philosophy, so it has a very clear idea how things should work (single request context passed around as the first argument to all components that participate in a response generation, avoiding side effects where possible, MVC-inspired architecture, etc.). Phoenix Framework, in my mind, holds very close to the middle of this scale for these reasons: Worth noting that neither group is strictly better than the other – each has its usecases. Of course, most frameworks are not on an extreme end of the scale, but the distinction is there. In this category, the most popular examples are Django and Ruby on Rails. Of course, these kinds of frameworks are also extendable, but built-in tools often get embedded so deep into the project that they are almost irreplaceable. They guide the developer into optimal code structure and typically strive to provide a single favored way of doing things. Strict “batteries included” frameworks bring with them a complete set of tools to perform common web development tasks, as well as a set of conventions to go with it. On the flip side, apps built on such a foundation can, given poor governance, slowly evolve into an unsupportable mess of incompatible plugins and mismatched coding styles. As a result, they are very flexible those with a large community have extensions to perform any task imaginable. They enforce little to no rules for the structure of your applications and rely on the community to come up with the extensions and best practices. Most Go frameworks are like this, as well as ExpressJS. Flexible “DIY” frameworks are a little more than a set of utilities for the most common web-related tasks. Modern web frameworks can be roughly divided into two camps: Striking a balance between flexibility and strictness Apart from the whole framework being surprisingly well thought through, there are a few things that strike me as being done exceptionally well in Phoenix, compared to the rest of modern web frameworks.ġ. I dabbled in Phoenix for a while now, but never really got my hands dirty with it right up until now.
""" end true def handle_event( "toggle-status", _params, socket) do current_user = socket. inline-flex items-center transition ease-in-out duration-150 cursor-not-allowed">
#Elixir phoenix components update#
Now let’s update our file lib/instagram_clone_web/live/user_live/profile.ex:ĭefmodule do use InstagramCloneWeb, :live_component alias InstagramClone.Accounts true def update(assigns, socket) do get_btn_status(socket, assigns) """ def list_followers(user) do user = user |> Repo. """ def list_following(user) do user = user |> Repo. """ def following?(follower_id, followed_id) do Repo. Def live_view do quote do use Phoenix.LiveView,