Why were Phoenix Contexts introduced? A (brief) history.
People frequently struggle with Phoenix Contexts. They ask, 'Why were they introduced?' A brief history of why they were introduced might be helpful.
People frequently struggle with Phoenix Contexts. They ask, 'Why were they introduced?' A brief history of why they were introduced might be helpful.
What should we name our own βlinkβ component in a Phoenix codebase? We cannot call it <.link> because that comes with Phoenix out of the box. This is what I do.
LiveView 1.0 removes the `phx-feedback-for` annotation and introduces a new `used_input?/2` helper instead! Check out how to upgrade and use it.
I don't know about you, but I hate it when I'm filling out a long form and for some reason it disconnects, reconnects and I lose all of my form data. π± Thankfully LiveView ships with automatic form recovery!
Sometimes we want to test how our LiveView looks when it's disconnected. We could terminate our server and see, but there's a cooler little trick we can use.
If you recently upgraded to phoenix_live_reload 1.5 without looking at the changelog you may have missed an awesome update.
When we create modals, we can create a bad experience if we consider which elements should be focused. Thankfully, LiveView comes with awesome helpers to help us deal with that.
Do you ever want to focus an input when your LiveView page first loads? Well, I've got the trick for you.
Aren't you tired of writing {:ok, socket}, {:noreply, socket}? It breaks apart those beautiful pipes! Well, I have the solution for you!
Ever want to handle a LiveView action (event, message, patch, etc.) across several LiveViews without having to duplicate the code? LiveView's attach_hook/4 helper is the thing for you!
LiveView 0.20 ships with a new start_async/3 function that makes it so easy to perform arbitrary async operations while keeping the same process isolation and error handling we get with assign_async/3.
You probably know that the `:page_title` assign is special in Phoenix -- it is the only dynamic assign in a layout. I always wondered: how does it work? How do they make it special? So, I did a bit of code spelunking. π€Ώ
With LiveView's new async assigns, we can now load data asynchronously like a breeze. But how do we test it since we have async behavior? π€
LiveView 0.20 ships with a new `assign_async/3` function that makes adding async data on mount a breeze!
Phoenix LiveView 0.20 just dropped! It comes with a nice quality of life improvement to debug HEEX templates. Check it out!
If you have complex forms that you want to decouple from the database, we can use Ecto's embedded schemas to back a form. That gives us all the power of Ecto changesets without having to tie our form to our database schema.
Typically, we back Phoenix forms with an Ecto changeset. But sometimes, I prefer having more separation between the UI and the changeset that stores data in the database. Check out how we can use the new `to_form/2` helper to do just that.
Check out how this single line change allowed me to remove my entire InfiniteScroll JS hook and keep my infinite scroll working!
The best way to write LiveView tests: follow the familiar setup-exercise-verify testing pattern
I only recently learned that you can inline `if` and `for` statements in HEEX templates because they're special forms.
Want to get Heroicons Phoenix 1.7.2-style but have an existing app? This is what I do.
Anytime I need to inspect a page when testing LiveView, I reach for `open_browser/2`.
An awesome Phoenix LiveView Helper that lets us see how our LiveView responds when our users are not sitting close to our servers. π₯
Phoenix LiveView comes with so many helpers to improve the developer experience. One of those is liveSocket.enableDebug()
Check out the new `JS.exec/3` function that shipped with Phoenix 1.7.2 and why we might want to use it
An awesome Phoenix LiveView Helper that lets us see how our LiveView responds when our users are not sitting close to our servers. π₯
We often want to override CSS classes to customize styles in Phoenix function components. Check out how to do it.
There are 2 ways to test Phoenix function components. But I recommend only using one of them!
Phoenix has a lovely `:global` attribute type that allows us to pass all standard HTML attributes with one declaration. β¨
Delete LiveView stream elements with a `stream_delete_by_dom_id/3` to avoid having to load the full record into memory π₯³
Someone asked me how to animate deleting elements in LiveView. The trick is to use `LiveView.JS`.
Just recently learned that we can animate elements when they're first mounted on the page. Check it out!
LiveView just shipped a new concept of streams to deal with large collections without keeping data in memory. I gotta say, I like the ergonomics! π
LiveView ships with an awesome `form/3` test helper! Never test a form without it!
LiveView 0.18 consolidated `live_redirect/2`, `live_patch/2`, and `link/2` functions into a new `link` component. Check it out!
LiveView 0.18 introduced declarative assigns for components. This is how they work.
When using Phoenix 1.7's verified routes, I thought we were going to have to string interpolate each query param! π± Thankfully, the Phoenix team already thought of a better way.
I love `mix help` to get the docs for mix tasks right from the command line.
I just updated my `.projections.json` file to handle Phoenix 1.7's new components and view-like HTML modules.
Phoenix 1.7 deprecated `get_flash/2`. Thereβs a new `Phoenix.Flash.get/2` function to access flash data.
I wanted to test how easy it was to add Bandit as a web server in Phoenix 1.7 since it ships with alternative web server support. Turns out, it's incredibly easy!
Phoenix 1.7 is View-less! π± Controllers now render via a format-based Elixir modules (e.g. `GreetHTML`)
There's a new `--info PATH` flag for `mix phx.routes` task (e.g. `mix phx.routes --info /posts`) in Phoenix 1.7.