Skip to content

Instantly share code, notes, and snippets.

@MonkeyIsNull
Created November 4, 2015 02:16
Show Gist options
  • Save MonkeyIsNull/13aec9eac86489db15f2 to your computer and use it in GitHub Desktop.
Save MonkeyIsNull/13aec9eac86489db15f2 to your computer and use it in GitHub Desktop.
defmodule Rdd do
def top() do
threads = Reddhl.pull("elixir")
{ Reddhl.url(threads, 1), Reddhl.title(threads, 1) }
end
def top_five do
threads = Reddhl.pull("elixir")
Enum.map(0..4, fn(x) -> { Reddhl.url(threads, x), Reddhl.title(threads, x) } end)
end
def fetch(num) do
threads = Reddhl.pull("elixir")
{ Reddhl.url(threads, num), Reddhl.title(threads, num) }
end
def looper([]) do
end
def looper([hd|tail]) do
IO.inspect Task.await(hd)
looper(tail)
end
def task_five do
Enum.map(0..4, fn(x) -> Task.async(Rdd, :fetch, [x]) end)
end
# This is the PUB API
def fetch_top_five do
looper task_five
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment