Created
November 10, 2021 12:32
-
-
Save TylerPachal/9a7291fb9ba1c4bc8dcfdb39a6020cd6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Without specifying a child_spec, you get the default one: | |
# default = %{ | |
# id: __MODULE__, | |
# start: {__MODULE__, :start_link, [init_arg]} | |
# } | |
# A: calls start_link/1 with empty list of args | |
# children = [ | |
# DevWorker | |
# ] | |
# | |
# "start_link/1" | |
# [] | |
# B: Calls start_link/1 with single arg | |
# children = [ | |
# {DevWorker, :foo} | |
# ] | |
# | |
# "start_link/1" | |
# :foo | |
# C: Calls start_link/1 with the same list of args | |
# children = [ | |
# {DevWorker, [:foo, :bar]} | |
# ] | |
# | |
# "start_link/1" | |
# [:foo, :bar] | |
# With a custom child_spec: | |
# | |
# def child_spec([a, b]) do | |
# %{ | |
# id: make_ref(), | |
# start: {__MODULE__, :start_link, [a, b]} | |
# } | |
# end | |
# | |
# children = [ | |
# {DevWorker, [:foo, :bar]} | |
# ] | |
# | |
# "start_link/2" | |
# :foo | |
# :bar | |
def child_spec([a, b]) do | |
%{ | |
id: make_ref(), | |
start: {__MODULE__, :start_link, [a, b]} | |
} | |
end | |
def start_link(a) do | |
IO.inspect("start_link/1") | |
IO.inspect(a) | |
end | |
def start_link(a, b) do | |
IO.inspect("start_link/2") | |
IO.inspect(a) | |
IO.inspect(b) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment