std.lib.watch

process-options

added in 3.0

(process-options opts f)

helper function for building a watch function

(watch/process-options {:supress true :diff true :mode :async :args 2} (fn _ _ 1))

watch:add

added in 3.0

(watch:add obj f)(watch:add obj k f)(watch:add obj k f opts)

Adds a watch function through the IWatch protocol

watch:clear

added in 3.0

(watch:clear obj)(watch:clear obj opts)

Clears all watches form the object

watch:copy

added in 3.0

(watch:copy to from)(watch:copy to from opts)

Copies watches from one object to another

watch:list

added in 3.0

(watch:list obj)(watch:list obj opts)

Lists watch functions through the IWatch protocol

watch:remove

added in 3.0

(watch:remove obj)(watch:remove obj k)(watch:remove obj k opts)

Removes watch function through the IWatch protocol

watch:set

added in 3.0

(watch:set obj watches)(watch:set obj watches opts)

Sets a watch in the form of a map

wrap-diff

added in 3.0

(wrap-diff f)

only functions when the inputs are different

((watch/wrap-diff (fn _ _ p n (+ p n))) nil nil 2 2) => 2

((watch/wrap-diff (fn _ _ p n (+ p n))) nil nil 2 3) => 5

wrap-mode

added in 3.0

(wrap-mode f mode)

changes how the function is run, :sync (same thread) and :async (new thread)

wrap-select

added in 3.0

(wrap-select f sel)

enables operating on a given key

((watch/wrap-select (fn _ _ p n (+ p n)) :a) nil nil {:a 2} {:a 1}) => 3

wrap-suppress

added in 3.0

(wrap-suppress f)

runs the function but if errors, does not throw exception