How to cancel a Process message in Elixir
TIL that we can cancel a Process.send_after/4
message before it happens by calling Process.cancel_timer/1
:
ref = Process.send_after(self(), :process, 1000)
...
Process.cancel_timer(ref)
So we just need to keep the reference
on your GenServer so we can possibly cancel later.
Thanks @mwoods79
Tweet