Skip to content

Commit

Permalink
Add Kino.nothing/0
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Nov 25, 2021
1 parent db835f5 commit 2163ce3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/kino.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,20 @@ defmodule Kino do
`inspect/2`.
'''

@type nothing :: :"do not show this result in output"

@doc """
Sends the given term as cell output.
This allows any Livebook cell to have multiple evaluation
results. You can think of this function as a generalized
`IO.puts/2` that works for any type.
"""
@spec render(term()) :: :"do not show this result in output"
@spec render(term()) :: nothing()
def render(term) do
output = Kino.Render.to_livebook(term)
Kino.Bridge.put_output(output)
:"do not show this result in output"
nothing()
end

@doc """
Expand Down Expand Up @@ -166,7 +168,7 @@ defmodule Kino do
pos_integer(),
term(),
(term() -> {:cont, term(), acc :: term()} | :halt)
) :: :"do not show this result in output"
) :: nothing()
def animate(interval_ms, acc, fun) do
widget = Kino.Frame.new()

Expand All @@ -183,4 +185,12 @@ defmodule Kino do

Kino.render(widget)
end

@doc """
Returns a special value that results in no visible output.
"""
@spec nothing() :: atom()
def nothing() do
:"do not show this result in output"
end
end

0 comments on commit 2163ce3

Please sign in to comment.