Qqwy

Qqwy

TypeCheck Core Team

Clever OTP tricks

What things in OTP-land using Processes, GenServers, Supervision Trees and the likes have you come across and found clever enough to tell other people about?


I myself recently learned about Process.send_after/3, and that it is entirely possible for a process to itself call send_after to remind itself about something later. I really like how one can combine it with GenServer.handle_info/2 to basically create a Process that ‘lets itself tick’.

It might have somewhat limited uses, but for my use case (entities governed by finite state machines that might change state depending on passed time) it works really gracefully.

Most Liked

gausby

gausby

Notice for state machines using the :gen_fsm behaviour there are some functions dealing with sending delayed events and messages to the process itself, such as start_timer/2 which will send a term to the current state in the form {:timeout, _timer, *term*}; and send_event_after/2 which will send a change event message to the state machine. Both returns a reference that can be used to cancel the timer using cancel_timer/1.

Where Next?

Popular in Discussions Top

PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
ricklove
I was just introduced to Elixir and Phoenix. I was told about the 2 million websocket test that was done 2 years ago. From my research, t...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 14362 124
New
eteeselink
Hi all, In the last days, two things happened: A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44608 311
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement