File size: 873 Bytes
8752997
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import "phoenix_html"
import {Socket} from "phoenix"
import {LiveSocket} from "phoenix_live_view"

let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}})

liveSocket.connect()
window.liveSocket = liveSocket
```

10. lib/hexalixir/application.ex:
```elixir
defmodule Hexalixir.Application do
  use Application

  @impl true
  def start(_type, _args) do
    children = [
      HexalixirWeb.Telemetry,
      {Phoenix.PubSub, name: Hexalixir.PubSub},
      HexalixirWeb.Endpoint,
      Hexalixir.Game
    ]

    opts = [strategy: :one_for_one, name: Hexalixir.Supervisor]
    Supervisor.start_link(children, opts)
  end

  @impl true
  def config_change(changed, _new, removed) do
    HexalixirWeb.Endpoint.config_change(changed, removed)
    :ok
  end
end