Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule MyApplication.Recurring do
- use GenServer
- def start_link() do
- GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
- end
- def init(:ok) do
- schedule()
- {:ok, %{}}
- end
- defp schedule do
- Process.send_after(self(), :do_work, 15 * 1000)
- end
- def handle_info(:do_work, state) do
- IO.puts "My recurring task!!"
- schedule()
- {:noreply, state}
- end
- end
Add Comment
Please, Sign In to add comment