GrovePi v0.3.2 GrovePi.Trigger behaviour View Source
The Trigger behaviour is used for implementing triggers for poller
behaviors such as GrovePi.Sound
and GrovePi.Button
. The triggers
must implement two callbacks, init and update.
Link to this section Summary
Callbacks
The init callback that must return {:ok, state}
or an error tuple
The update callback receives a new value and a trigger state and returns
a tuple of {:event_name, new_state}
Link to this section Types
Link to this section Callbacks
Link to this callback
init(args)
View Source
init(args :: term) :: {:ok, state} | {:error, reason :: any}
The init callback that must return {:ok, state}
or an error tuple.
The update callback receives a new value and a trigger state and returns
a tuple of {:event_name, new_state}
.
If no event is needed to fire return {:ok, new_state}
.