Skip to content

Commit

Permalink
Change Kino.render/1 to return hidden value (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Jul 28, 2021
1 parent 09e3d4d commit 5279cc8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/kino.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule Kino do
|> Vl.data_from_series(...)
|> ...
|> Kino.VegaLite.new()
|> Kino.render()
|> tap(&Kino.render/1)
Kino.VegaLite.push(widget, %{x: 1, y: 2})
Expand Down Expand Up @@ -103,7 +103,7 @@ defmodule Kino do
results. You can think of this function as a generalized
`IO.puts/2` that works for any type.
"""
@spec render(term()) :: term()
@spec render(term()) :: :"do not show this result in output"
def render(term) do
gl = Process.group_leader()
ref = Process.monitor(gl)
Expand All @@ -119,7 +119,7 @@ defmodule Kino do

Process.demonitor(ref)

term
:"do not show this result in output"
end

@doc """
Expand Down
6 changes: 3 additions & 3 deletions lib/kino/vega_lite.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ defmodule Kino.VegaLite do
## Examples
vl_widget =
widget =
Vl.new(width: 400, height: 400)
|> Vl.mark(:line)
|> Vl.encode_field(:x, "x", type: :quantitative)
|> Vl.encode_field(:y, "y", type: :quantitative)
|> Kino.VegaLite.new()
|> Kino.render()
|> tap(&Kino.render/1)
for i <- 1..300 do
point = %{x: i / 10, y: :math.sin(i / 10)}
Kino.VegaLite.push(vl_widget, point)
Kino.VegaLite.push(widget, point)
Process.sleep(25)
end
"""
Expand Down
6 changes: 3 additions & 3 deletions test/kino/ecto_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ defmodule Kino.EctoTest do
assert_receive {from, [MockRepo, :aggregate, query: _, aggregate: :count, opts: []]}
MockRepo.resolve_call(from, 0)

assert_receive {_from, [MockRepo, :all, query: %{offset: offset, limit: limit}, opts: []]}
assert_receive {from, [MockRepo, :all, query: %{offset: offset, limit: limit}, opts: []]}
MockRepo.resolve_call(from, [])

assert Macro.to_string(offset.expr) == "^0"
Expand All @@ -261,7 +261,7 @@ defmodule Kino.EctoTest do
assert_receive {from, [MockRepo, :aggregate, query: _, aggregate: :count, opts: []]}
MockRepo.resolve_call(from, 0)

assert_receive {_from, [MockRepo, :all, query: %{order_bys: [order_by]}, opts: []]}
assert_receive {from, [MockRepo, :all, query: %{order_bys: [order_by]}, opts: []]}
MockRepo.resolve_call(from, [])

assert Macro.to_string(order_by.expr) == "[asc: &0.name()]"
Expand All @@ -281,7 +281,7 @@ defmodule Kino.EctoTest do
assert_receive {from, [MockRepo, :aggregate, query: _, aggregate: :count, opts: []]}
MockRepo.resolve_call(from, 0)

assert_receive {_from, [MockRepo, :all, query: %{order_bys: [order_by]}, opts: []]}
assert_receive {from, [MockRepo, :all, query: %{order_bys: [order_by]}, opts: []]}
MockRepo.resolve_call(from, [])

assert Macro.to_string(order_by.expr) == "[desc: &0.id()]"
Expand Down

0 comments on commit 5279cc8

Please sign in to comment.