Skip to content

Commit

Permalink
Add Kino.start_child!/1
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Aug 29, 2023
1 parent 8688d80 commit 0d83dc4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/kino.ex
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,18 @@ defmodule Kino do
DynamicSupervisor.start_child(Kino.DynamicSupervisor, child_spec)
end

@doc """
Similar to `start_child/2` but returns the new pid or raises an error.
"""
@spec start_child!(Supervisor.child_spec() | {module(), term()} | module()) :: pid()
def start_child!(child_spec) do
case start_child(child_spec) do
{:ok, pid} -> pid
{:ok, pid, _info} -> pid
other -> raise "failed to start child, reason: #{Kernel.inspect(other)}"
end
end

@doc """
Terminates a child started with `start_child/1`.
Expand Down

0 comments on commit 0d83dc4

Please sign in to comment.