Skip to content

Kotlin API wrapper for Java's WatchService powered with Channels and Coroutines. a.k.a. KWatchChannel

License

Notifications You must be signed in to change notification settings

vishna/watchservice-ktx

Repository files navigation

watchservice-ktx

Kotlin API wrapper for Java's WatchService powered with Channels and Coroutines. a.k.a. KWatchChannel

Getting started

This repository is hosted via jitpack since it's by far the easiest delivery method while also being pretty transparent to the developer.

Make sure you have added jitpack to the list of your repositories:

maven("https://jitpack.io")

Then simply add the watchservice-ktx dependency

dependencies {
  compile("com.github.vishna:watchservice-ktx:master-SNAPSHOT")
}

Example usage

val currentDirectory  = File(System.getProperty("user.dir"))

val watchChannel = currentDirectory.asWatchChannel()

launch {
  watchChannel.consumeEach { event ->
    // do something with event
  }
}

// once you no longer need this channel, make sure you close it
watchChannel.close()

For more documentation on API see watchservice.kt or check out the medium article

About

Kotlin API wrapper for Java's WatchService powered with Channels and Coroutines. a.k.a. KWatchChannel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages