瀏覽代碼

added unregisterElement

Nicolas Cannasse 5 年之前
父節點
當前提交
314031cac7
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      hide/tools/FileWatcher.hx

+ 12 - 0
hide/tools/FileWatcher.hx

@@ -50,6 +50,18 @@ class FileWatcher {
 		}
 		}
 	}
 	}
 
 
+	public function unregisterElement( element : Element ) {
+		for( path => w in watches ) {
+			for( e in w.events.copy() )
+				if( e.element == element[0] )
+					w.events.remove(e);
+			if( w.events.length == 0 ) {
+				watches.remove(path);
+				if( w.w != null ) w.w.close();
+			}
+		}
+	}
+
 	function cleanEvents() {
 	function cleanEvents() {
 		for( w in watches )
 		for( w in watches )
 			for( e in w.events.copy() )
 			for( e in w.events.copy() )