Skip to content

Instantly share code, notes, and snippets.

@mysteriouspants
Forked from stochastic-thread/life.ex
Last active August 29, 2015 14:23
Show Gist options
  • Save mysteriouspants/351e85b330d3fd6d9b73 to your computer and use it in GitHub Desktop.
Save mysteriouspants/351e85b330d3fd6d9b73 to your computer and use it in GitHub Desktop.
defmodule Life do
def start do
spawn(fn -> listen() end)
end
defp listen() do
receive do
{:add, url} ->
loop(url)
end
end
defp loop(url) do
IO.puts "hey"
resp = HTTPoison.get! url
json_body = Poison.decode! resp.body
list = json_body["data"] |> Enum.map fn(x) -> x["images"]["standard_resolution"]["url"] end
send self(), {:add, json_body["pagination"]}
IO.puts list_perm
loop(list_perm ++ list)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment