hs.watchable.new(path, [externalChanges]) -> table
path
- the global name for this internal table that external code can refer to the table as.externalChanges
- an optional boolean, default false, specifying whether external code can make changes to keys within this table (bi-directional communication).hs.watchable.watch(path, [key], callback) -> watchableObject
path
- a string specifying the path to watch. If key
is not provided, then this should be a string of the form "path.key" where the key will be identified as the string after the last "."key
- if provided, a string specifying the specific key within the path to watch.callback
- an optional function which will be invoked when changes occur to the key specified within the path. The function should expect the following arguments:watcher
- the watcher object itselfpath
- the path being watchedkey
- the specific key within the path which invoked this callbackold
- the old value for this key, may be nilnew
- the new value for this key, may be nilhs.watchable:callback(fn) -> watchableObject
fn
- a function, or an explicit nil to remove, specifying the new callback function to receive notifications for this watchableObjecths.watchable:change([key], value) -> watchableObject
key
- if the watchableObject was defined with a key of "*", this argument is required and specifies the specific key of the watched table to change the value of. If a specific key was specified when the watchableObject was defined, this argument must not be provided.value
- the new value for the key.hs.watchable:pause() -> watchableObject
hs.watchable:release() -> nil
hs.watchable:resume() -> watchableObject
hs.watchable:value([key]) -> currentValue
key
- if the watchableObject was defined with a key of "*", this argument is required and specifies the specific key of the watched table to retrieve the value for. If a specific key was specified when the watchableObject was defined, this argument is ignored.