defmodule LivebookWeb.SessionLive.AttachedLive do use LivebookWeb, :live_view alias Livebook.{Session, Runtime, Utils} @impl true def mount(_params, %{"session" => session, "current_runtime" => current_runtime}, socket) do unless Livebook.Config.runtime_enabled?(Livebook.Runtime.Attached) do raise "runtime module not allowed" end if connected?(socket) do Session.subscribe(session.id) end {:ok, assign(socket, session: session, current_runtime: current_runtime, error_message: nil, data: initial_data(current_runtime) )} end @impl true def render(assigns) do ~H"""
Connect the session to an already running node and evaluate code in the context of that node. Thanks to this approach you can work with an arbitrary Elixir runtime. Make sure to give the node a name and a cookie, for example:
iex --name test@<%= longname %> --cookie mycookie
<% else %>
iex --sname test --cookie mycookie
<% end %>
Then enter the connection information below:
<.form :let={f} for={:data} phx-submit="init" phx-change="validate" autocomplete="off" spellcheck="false" >