Skip to content

Commit

Permalink
Add nothing to Kino.Shorts
Browse files Browse the repository at this point in the history
  • Loading branch information
christhekeele committed Oct 3, 2024
1 parent 11d6828 commit 4562cce
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/kino/shorts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,44 @@ defmodule Kino.Shorts do
"""

@doc """
Returns a special value that results in no visible output.
It is a wrapper around `Kino.nothing/0`.
## Examples
Supress an otherwise verbose cell's output:
import Kino.Shorts
resp = Req.get!("https://example.org")
output_nothing()
For convenience, you can pipe anything into `output_nothing()`
to terminate a pipeline of Kinos that control their own rendering:
import Kino.Shorts
frame = frame() |> Kino.render
frame |> Kino.Frame.render(markdown("> ***Sumbit an event***"))
Kino.Control.form(
[name: Kino.Input.text("Event Name", default: "default")],
submit: "Render Event"
)
|> Kino.render
|> Kino.listen(fn
event ->
Kino.Frame.clear(frame)
Kino.Frame.render(frame, markdown("`\#{inspect event}`"))
end)
|> output_nothing()
"""
@spec output_nothing() :: Kino.nothing()
@spec output_nothing(term()) :: Kino.nothing()
def output_nothing(_ \\ nil), do: Kino.nothing()

## Outputs

@doc """
Expand Down

0 comments on commit 4562cce

Please sign in to comment.