lubyk logo

Lubyk documentation

FileWatch

Watches a file and executes the changed callback if the content changes. Uses kevent or other OS optimized notification so that listening to files takes as few resources as possible.

See LiveCoding example.

Constructor

.new (path, callback)

Start listening to the file provided by path. If path is omitted, the default is the calling script's path. If callback is omitted, the default is to reload the script.

Callback

:changed ()

The callback function is called when the watched file changes. The default implementation is to reload the file (execute a dofile).