bradley

bradley

Would auto formatting/sorting phoenix liveview/live component callbacks make sense?

I’ve been recently been doing the “vibe coding” thing a lot using cursor and I’m finding that very frequently the models don’t group liveview callbacks appropriately, which results in compiler warning that kills the “vibe”.

For example, it’ll do something like:

def handle_event(...

def handle_info(...

def handle_event(...

Which will result in a compiler warning.

I just wanted to check in with folks, would it be crazy to consider auto sorting liveview callbacks?

I have a really hacky AI written fork of styler here that seems to work okay on my current codebase. If you’re curious about the very few cases that I’ve considered already, please see the tests for liveview here and the tests for liveview components here.

The TLDR is that it basically standardizes the order of callbacks, similar to credo’s StrictModuleLayout. The current liveview order of preference is:

  1. mount/3
  2. handle_params/3
  3. handle_event/3
  4. handle_info/2
  5. handle_async/2
  6. handle_call/3
  7. handle_cast/2
  8. update/2
  9. terminate/2
  10. render/1

And the live component order is:

  1. mount/1
  2. update/2
  3. update_many/1
  4. handle_event/3
  5. handle_async/2
  6. render/1

Does anyone else have interest in this kind of thing?

Edited

I do use rulesets and they don’t work 100% of the time for me which is why I’ve considered this solution for myself.

First Post!

munksgaard

munksgaard

Could it be a plugin to mix format? I would appreciate something that enforced a specific order in my live_view modules.

Where Next?

Popular in Questions Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement