Skip to content

Instantly share code, notes, and snippets.

@ryo33
Last active May 29, 2021 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryo33/7bf19f33a8aff4e934a510494d03d6e1 to your computer and use it in GitHub Desktop.
Save ryo33/7bf19f33a8aff4e934a510494d03d6e1 to your computer and use it in GitHub Desktop.
# 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