This module is useful if you want to track changes to a value.
Initialise a value.
init "Bob" -- Original "Bob"Updates a Resettable value.
-- update to new value
update "Joshua" (Original "Josh") -- Updated "Josh" "Joshua"
update "Bob" (Updated "Josh" "Joshua") -- Updated "Josh" "Bob"
-- if the new value is the original value or a changed value is set to it's original value, keep the original value
update "Josh" (Original "Josh") -- Original "Bob"
update "Josh" (Updated "Josh" "Joshua") -- Original "Josh"Reset to the original value.
reset (Original "Josh") -- Original "Josh"
reset (Updated "Josh" "Joshua") -- Original "Josh"Whether a value changed.
isChanged (Original "Josh") -- False
isChanged (Updated "Josh" "Joshua") -- True
when checking a lot of values, it may be helpful to put them in a list:
-- if they all have the same type:
List.any isChanged [ Original "Josh", Updated "Josh" "Joshua" ] -- True
-- if they have different types
List.any ((==) True) [ isChanged (Original "Josh"), isChanged (Original 12) ] -- FalseGet the current value.
getValue (Original "Josh") -- "Josh"
getValue (Updated "Josh" "Joshua") -- "Joshua"Get the original value.
getOriginalValue (Original "Josh") -- "Josh"
getOriginalValue (Updated "Josh" "Joshua") -- "Josh"
Represent values that may be original or updated. It can be useful if you have a a save button that should be disabled if nothing on a form changed.