Skip to content

Commit

Permalink
improve NervesDHT.stream
Browse files Browse the repository at this point in the history
  • Loading branch information
visciang committed Dec 9, 2017
1 parent 666aec6 commit 44c68ac
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/nerves_dht.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ defmodule NervesDHT do
"""
@spec stream(sensor, pin, interval) :: Enumerable.t
def stream(sensor, pin, interval \\ @delay) do
Stream.interval(interval)
|> Stream.map(fn(_) -> read(sensor, pin, 0, 0) end)
Stream.repeatedly(fn -> Process.sleep(interval); read(sensor, pin, 0, 0) end)
end

@doc """
Expand Down

0 comments on commit 44c68ac

Please sign in to comment.