Guest User

Untitled

a guest
Mar 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. defmodule Phoenix.SchedulePost do
  2. use GenServer
  3.  
  4. def start_link(state) do
  5. GenServer.start_link __MODULE__,state
  6. end
  7.  
  8. def init(state) do
  9. schedule_post(state)
  10. {:ok, state}
  11. end
  12. #handling looby
  13. def handle_info(:postSchedule,state) do
  14. #sending posts to others
  15. {:noreply,state}
  16. end
  17. #scheduling a task
  18. defp schedule_post(state) do
  19. IO.puts "scheduling the task"
  20. Process.send_after(self(),:postSchedule,1*60*1000)
  21. end
  22. end
  23.  
  24. Phoenix.SchedulePost.start_link(postId);
Add Comment
Please, Sign In to add comment