Files
orx/orx-jvm/orx-file-watcher
2022-06-19 08:06:16 +02:00
..
2021-06-22 11:08:07 +02:00

orx-file-watcher

Monitor files on disk and auto-reload them if they change.

Usage

Monitoring a single file.

application {
    program {
        val watchedText = watchFile(File("someFile.txt")) {
            it.readText()
        }
        extend {
            val theText = watchedText()
        }
    }
}

Making a map of monitored files.

application {
    program {
        val watchedTexts = mutableMap<String, ()->String>()
         watchedTexts["text"] = watchFile(File("someFile.txt")) {
            it.readText()
         }

        extend {
            val theText = watchedTexts.getValue("text")()
        }
    }
}