Today I Learned

hashrocket A Hashrocket project

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

See More #elixir TILs
Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.