Joining channels on the client

Having prepared the server, we'll now explore the client side of Phoenix Channels. First, we'll quickly go through the structure that Phoenix has generated for us, and then see how we can update it. The last line in our application layout, before closing the body, is:

<script src="<%= static_path(@conn, "/js/app.js") %>"></script>

This requires the app.js file, which is stored in apps/elixir_drip_web/assets /js/app.js. This is the entry point for our JavaScript code. Let's analyze its contents now:

$ cat apps/elixir_drip_web/assets/js/app.js import "phoenix_html"import socket from "./socket"import Notification from "./notification"Notification.init(socket, window.userId)

The first two lines were generated by ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.