Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add shortcut to nothing in Kino.Shorts #473

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading