#
cp.watcher
This extension provides support for setting up 'event watchers'.
For example, if you want to allow interested parties to watch for 'update' events, you might have something like this:
local thing = {}
thing.watchers = watcher.new('update')
thing.watch(events)
return thing.watchers:watch(events)
end
thing.update(value)
thing.value = value
thing.watchers:notify('update', value)
end
Then, your other code could get notifications like so:
thing.watch({
update = function(value) print "New value is "..value end
})
Then, whenever thing.update(xxx)
is called, the watcher will output "New value is xxx"
.
#
API Overview
Functions - API calls offered directly by the extension
new
Methods - API calls which can only be made on an object returned by a constructor
events getCount notify unwatch watch