Stops the watcher and disconnects everything connected to its events. No further events fire.

Behavior

  • Handlers are disconnected for you. The event objects are destroyed, so you do not need to keep and disconnect each connection yourself.
  • Safe to call twice. A second Destroy does nothing.
  • The object becomes inert. Afterwards Path reads nil, and writing Recursive is ignored rather than raising.
  • Not tied to garbage collection. A watcher keeps running until you destroy it or the session ends, so a DirectoryWatcher.new(...) whose result you do not keep will go on firing.

Example

Errors