Current section
Files
Jump to
Current section
Files
lib/examples/double_dependencies.ex
defmodule TwoDep do
@moduledoc
"""
TwoDep showcases multiple dependencies.
The example shows a function being applied to seconds and temperature.
When the seconds ticks, it will print out the last value generated by the
temperature sensor. If no value is available the initial value will be used.
"""
use Reactivity
def temperature_log(time, temp) do
IO.puts "Temperature: #{temp} @ #{time}"
end
def app() do
# Capture the signals from the registry.
tempS = source(:temperature)
timeS = source(:seconds)
# Create a lifted function.
lifted = lift2(&temperature_log/2)
# Apply the function.
apply2(tempS, timeS, lifted)
end
end