Are Phoenix Channels still a thing in 2022?

Hello,

I’m following along the book “Programming Phoenix >= 1.4” and Channels are brought up around page 200.

I’ve already played with LiveView prior to buying this book, and I understood that LiveView sits on top of the Channels concept.

Now that LiveView exists, does it make sens to use a Channel-only solution or are there no practical reasons to do so?

I’m asking since I can gather that Channels were a concept baked into the defaults, and those defaults have switched over to LiveView.

I’m wondering if it’s worth spending time learning Channels, or if I’d better spend my time implementing this portion of the book with straight LiveView (I’m fine doing both)

Thanks :slight_smile:

2 Likes

Channels are perfect if you want to use a javascript front end. They’re also pretty useful for clients that want to use a websocket to subscribe to data in realtime like a mobile app or even other backend services.

13 Likes

Great, thanks @benwilson512 :slight_smile:

Though a little ensure, I did think about javascript clients, but definitely not about mobile apps and even less other backends.

Good to know :+1:

1 Like

I had that same question: “Does LiveView supersede channels?”

I really like Ben’s answer. Thanks for that!

There are a few elixir-elixir libraries for this. I use the former for multi client to server style comms to great success.

https://hexdocs.pm/slipstream/Slipstream.html

Thanks! I hope they remain important, and the creators of Phoenix don’t abandon them. I have just started learning them and plan to use them :slight_smile:

1 Like

They’re the backbone of a lot of the cool things in the ecosystem, including liveview and phx presence—they’re not going anywhere. :slight_smile:

3 Likes

Nice! Thinking about connecting backends again, when would you favor using such a channels client over implementing and connecting to a gen server?

The only thing I can think of is using channels could be more practical when crossing WANs.

I understood I can offload processes to other nodes with Erlang/Elixir tech, but no security (must implement some kind of private network)

Well, I’m not talking about connecting backends per se. When I was looking into it the advice seemed to be “if you can do it without using Erlang distribution, then do so. It will be easier”. By it, I mean connecting X clients to a server, where clients are applications running on PCs on a LAN.

Got ya, seems like I wrongly assumed the use case for your lib :slight_smile: