Browse Source

added unregisterElement

Nicolas Cannasse 5 years ago
parent
commit
314031cac7
1 changed files with 12 additions and 0 deletions
  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() {
 		for( w in watches )
 			for( e in w.events.copy() )