defmodule Reactivity.Test do require Integer require Logger alias Reactivity.Signal.Source import Reactivity def hot_cold(t) do if t > 30 do "hot" else "cold" end end def init do {:ok, t} = Source.new(fn(_old_value) -> Enum.random(10..100) end, -1, 100, :temperature) #{:ok, h} = Source.new(fn(_old_value) -> Enum.random(60..100) end, -1, 100, :humidity) end def test do # Create a new signal :hotcold based on the source :temperature. source(:temperature) |> liftapp(&hot_cold/1) |> register(:hotcold) # Create a new signal :kelvin based on the source :temperature source(:temperature) |> liftapp(&(&1 + 237.15)) |> register(:kelvin) |> liftapp(&(IO.puts &1)) # Print out hot/cold for the kelvin signal source(:kelvin) |> liftapp(&hot_cold/1) |> liftapp(&(Logger.debug "Kelvin: #{&1}")) end end