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 743cb75
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/kino/frame.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ 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 +120,13 @@ 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 743cb75

Please sign in to comment.