This repository was archived by the owner on Feb 14, 2020. It is now read-only.
v0.1.3
Introduce RxScala interface for monitoring
This version brings a new Observable interface that exposes a "stream" (or channel) of EventAtPath
s that can be composed. For more information, checkout the Rx homepage
Example:
import com.beachape.filemanagement.RxMonitor
import java.io.{FileWriter, BufferedWriter}
import java.nio.file.Paths
import java.nio.file.StandardWatchEventKinds._
val monitor = RxMonitor()
val observable = monitor.observable
val subscription = observable.subscribe(
onNext = { p => println(s"Something was modified in a file mufufu: $p")},
onError = { t => println(t)},
onCompleted = { () => println("Monitor has been shut down") }
)
val desktopFile = Paths get "/Users/lloyd/Desktop/test"
monitor.registerPath(ENTRY_MODIFY, desktopFile)
Thread.sleep(100)
//modify a monitored file
val writer = new BufferedWriter(new FileWriter(desktopFile.toFile))
writer.write("Theres text in here wee!!")
writer.close
// #=> Something was modified in a file mufufu: /Users/lloyd/Desktop/test
// stop monitoring
monitor.stop()
// #=> Monitor has been shut down