title: How to create an event emitter with elixir, the otp way
body: <p>What is the best way in elixir to create a foreground process that tick on every given amount of time?</p>
  
  <p>My main problem is that an approach like:</p>
  
  <pre><code>defmoulde Ticker do
    def tick do
      do_something()
      :timer.sleep(1000)
      tick
    end
  end
  </code></pre>
  
  <p>works, but is wrong by design. It's definitely not ticking every second, but every second PLUS the time for do_something() to complete.
  I could spawn a process to handle the "something" but still there is a small lag.</p>
  
  <p>Also, I'm trying to build a mix app, there is some GenServers involved, and a main foreground process (the one I'm asking here) that should call the servers every x seconds. Is there an otp way of doing this?</p>