Last active
May 29, 2021 17:33
-
-
Save ryo33/7bf19f33a8aff4e934a510494d03d6e1 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
# Things to prepare | |
alias Cizen.Dispatcher | |
alias Cizen.Pattern | |
require Pattern | |
# Dispatch something | |
Dispatcher.dispatch(10) | |
Dispatcher.dispatch({:ok, %{body: "Hello World"}}) | |
# Listens numbers less than 10. | |
Dispatcher.listen(Pattern.new(fn x -> x < 10 end)) | |
# Dispatches and receives a number and prints it. | |
Dispatcher.dispatch(5) # must be less than 10 to receive | |
receive do | |
x -> IO.puts(x) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment