UNPKG

raptor

Version:

RaptorJS provides an AMD module loader that works in Node, Rhino and the web browser. It also includes various sub-modules to support building optimized web applications.

41 lines (33 loc) 1.3 kB
define.extend( 'raptor/file-watcher', function(require) { "use strict"; var Watcher = function(javaWatcher, file) { this.javaWatcher = javaWatcher; this.filename = file; }; Watcher.prototype = { closeWatcher: function() { this.javaWatcher.closeWatcher(); } }; return { watch: function(file, callback, thisObj, options) { var javaWatcher = null; var watcher = null, rhinoCallback = function(eventName, filename) { callback.call(thisObj, { event: eventName, filename: file, watcher: javaWatcher, closeWatcher: function() { watcher.close(); } }); }; javaWatcher = __rhinoHelpers.getFileWatcher().watchFile(file, rhinoCallback, this, options); watcher = new Watcher(javaWatcher, file); return watcher; } }; });