@lloydmeta lloydmeta released this May 1, 2014 · 96 commits to master since this release

Assets 2

Introduce RxScala interface for monitoring

This version brings a new Observable interface that exposes a "stream" (or channel) of EventAtPaths that can be composed. For more information, checkout the Rx homepage


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)


//modify a monitored file
val writer = new BufferedWriter(new FileWriter(desktopFile.toFile))
writer.write("Theres text in here wee!!")

// #=> Something was modified in a file mufufu: /Users/lloyd/Desktop/test

// stop monitoring

// #=> Monitor has been shut down