This is a library meant for library authors that want to build libraries that work across Java, Scala, or Kotlin, without having to worry about interoperability with whatever method of I/O that the library is using under the hood.
Read the Javadoc. Better documentation is coming.
The AsyncFun interface has changed to improve cancellation management and simplify the API. This is a source and binary incompatible change.
Old shape:
Task.fromAsync((executor, callback) -> {
// ...
return () -> { /* cleanup */ };
});New shape:
Task.fromAsync(continuation -> {
var executor = continuation.getExecutor();
continuation.invokeOnCancellation(() -> { /* cleanup */ });
// ...
});Key differences:
- The
executorandcallbackare now encapsulated in theContinuation. - Cancellation cleanup is registered via
continuation.invokeOnCancellation(finalizer)instead of returning aCancellable. continuation.onCancellation()signals that the task has completed due to cancellation, whereasinvokeOnCancellation(finalizer)registers a cleanup action to run when cancellation occurs.
Maven:
<dependency>
<groupId>org.funfix</groupId>
<artifactId>tasks-jvm</artifactId>
<version>0.4.1</version>
</dependency>Gradle:
dependencies {
implementation("org.funfix:tasks-jvm:0.4.1")
}sbt:
libraryDependencies += "org.funfix" % "tasks-jvm" % "0.4.1"