News for hackers. Stuff that matters.
Re:Use Phoenix Channels by losvedir on Wednesday August 04, 2021 @11:39AM (#28062274)
I'm so excited for Phoenix 1.6. I think Phoenix was almost onto gold with LiveView when introduced, but it was still a little rough around the edges. But Phoenix 1.6 should sand away all the roughness, and we'll be in an awesome place.

Basically, the issue before, IMO, was kind of a tension between "live controllers" and (they call them "dead" but I prefer "static") static controllers. You couldn't necessarily interleave them super well, and factored templates had issues when used in one place or another. (I'm not an expert here, this was just from some testing and dabbling.)

But now (or well, soon), there's going to be a unified "heex" format which works in both. You write components almost like React components, their structure is parsed to some extent to catch simple typos and bugs, and can pass in "props" as arguments. And said components can be re-used in both live and static controllers.

Basically, channels were Phoenix's killer feature, LiveView sort of abused them to show a promising new way of developing web apps, and now I'm hopeful we're just about at a point where Phoenix can settle down into a new normal with function components on hex.pm and easy and pervasive LiveView pages and widgets, added in easily to your existing, standard Phoenix apps.

And, combined with the recent announcement of the removal of node+npm+webpack by default, in favor of esbuild, I think Phoenix 1.6 is going to be a no-brainer choice for any new web apps going forward.

Re:Use Phoenix Channels by mrdoops on Wednesday August 04, 2021 @12:29PM (#28062975)
They're also separating out Phoenix.View so there will be less dependencies on using Phoenix view rendered templates for things like email or PDF generation outside of a web layer.
Re:Use Phoenix Channels by sergiotapia on Wednesday August 04, 2021 @01:55PM (#28064098)
I created a new app with Phoenix 1.6 using esbuild and mount LiveView components just like they were react components.

I'm done with client-side apps. I had no idea how SHIT the workflow was. I just got used to the stench. Good riddance to webpack too.

Re:Use Phoenix Channels by louissm_it on Wednesday August 04, 2021 @04:51PM (#28066137)
Heex templates alone are going to be a game changer. I've been looking for 1.6 updates every day - can't wait for the release.

I'm hoping the development of community libraries will pick up again. Coming from Rails, gems like Pagy, Ransack & Pundit are hard to live without.

Re:Use Phoenix Channels by porker on Thursday August 05, 2021 @01:15AM (#28070140)
Yes, community libraries are a key part of the overall experience of using a framework and being productive.
Re:Use Phoenix Channels by elcritch on Wednesday August 04, 2021 @09:03PM (#28068485)
Do you know if HEEX will support slots like in Surface? It really makes it easier to rewrite usable components.
Re:Use Phoenix Channels by chrismccord on Wednesday August 04, 2021 @10:22PM (#28069026)
Not with LV 0.16, but slots is one of our top priorities after Phoenix 1.6 / LV 0.16 is out
Re:Use Phoenix Channels by nickjj on Thursday August 05, 2021 @07:17AM (#28072180)
Is there a slot-like alternative for the time being? Or maybe a gist'able module that can be added to get preliminary slot support into 1.6?
Re:Use Phoenix Channels by jms55 on Wednesday August 04, 2021 @01:13PM (#28063579)
This is great news for me! Around 8 months ago I built a chess website using Phoenix (heavily using LiveView) and TailwindCSS. My two biggest complaints were exactly what you said:

1. LiveViews were kind of weird to fit in, as they were a separate format

2. Webpack was the bain of my existence, it was slow and hard to figure out as a first time webdev

Glad to hear this is being fixed! Looks like I'm going to have to go back and update the site

Re:Use Phoenix Channels by spiderice on Wednesday August 04, 2021 @12:07PM (#28062660)
Wow, this is great news! I had not heard about that, but making live and static controllers work together has always been a pain point for me. Even with that pain point Phoenix has been my go to. But fixing that will be huge.
Re:Use Phoenix Channels by conradfr on Wednesday August 04, 2021 @01:33PM (#28063821)
I haven't use LiveView since the introduction of components, it'll be a good occasion to try it again.

But to be honest about the "no-brainer" part, I'll probably stick to using Phoenix for apis and websockets because I'm personally firm on not using a framework that use the (IMHO) outdated layout->view model for displaying HTML.

Re:Use Phoenix Channels by spiderice on Wednesday August 04, 2021 @03:22PM (#28065089)
> the (IMHO) outdated layout->view model for displaying HTML

What is the modern model that you do use? Phoenix is very flexible and I'm wondering if it could easily be added manually.

Re:Use Phoenix Channels by conradfr on Wednesday August 04, 2021 @05:26PM (#28066560)
Template inheritance with blocks, as they do in Django or Symfony.

That way you don't have layouts anymore, but (usually) a base template that an action view overloads with its own content.

I know Ruby on Rails doesn't work like that so I guess that's why it didn't take in Phoenix (yet?).

Re:Use Phoenix Channels by porker on Thursday August 05, 2021 @01:16AM (#28070147)
Agreed. Once you're used to template inheritance it's hard to go back.
Re:Use Phoenix Channels by hifly on Wednesday August 04, 2021 @07:37PM (#28067838)
perhaps you could have a glance at "surface" and see if it's what you want? I think the new .heex format also gives the basis to build what you want even if surface isn't the answer for you?
Re:Use Phoenix Channels by therein on Wednesday August 04, 2021 @02:52PM (#28064735)
It is going to be good being able to pass props to these LiveView's. I remember that wasn't possible and I needed all sorts of workarounds.