Skip to content

Commit

Permalink
Make frame render functions return the frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
christhekeele committed Oct 3, 2024
1 parent e714459 commit 915aea0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/kino/frame.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ defmodule Kino.Frame do
updates are never a part of frame history
"""
@spec render(t(), term(), keyword()) :: :ok
@spec render(t(), term(), keyword()) :: t()
def render(frame, term, opts \\ []) do
opts = Keyword.validate!(opts, [:to, :temporary])
destination = update_destination_from_opts!(opts)
GenServer.call(frame.pid, {:render, term, destination}, :infinity)

with :ok <- GenServer.call(frame.pid, {:render, term, destination}, :infinity) do
frame
end
end

defp update_destination_from_opts!(opts) do
Expand Down Expand Up @@ -118,11 +121,14 @@ defmodule Kino.Frame do
updates are never a part of frame history
"""
@spec append(t(), term(), keyword()) :: :ok
@spec append(t(), term(), keyword()) :: t()
def append(frame, term, opts \\ []) do
opts = Keyword.validate!(opts, [:to, :temporary])
destination = update_destination_from_opts!(opts)
GenServer.call(frame.pid, {:append, term, destination}, :infinity)

with :ok <- GenServer.call(frame.pid, {:append, term, destination}, :infinity) do
frame
end
end

@doc """
Expand Down

0 comments on commit 915aea0

Please sign in to comment.