Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.


Choose a tag to compare
@lloydmeta lloydmeta released this 01 May 15:03
· 96 commits to master since this release

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{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