Chainy is a small util to help chain, different async requests together and build a final result.
Start by adding the jitpack repository to your project with the artifacts you want to use.
repositories {
mavenCentral()
mavenLocal()
maven("https://jitpack.io")
}
dependencies {
implementation("com.github.einnxk:chainy:1.0.0-SNAPSHOT")
}package dev.einnik.chainy.example;
import dev.einnik.chainy.Chain;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public class Example {
public CompletableFuture<PlayerProfile> loadProfile() {
public CompletableFuture<PlayerProfile> fetchPlayerProfile(UUID uuid) {
return Chain.startWith(0, () -> new PlayerDataState(uuid))
.then(1, state -> state.withName(loadName(state.uuid())))
.then(2, state -> state.withPlayTime(loadPlayTime(state.uuid())))
.thenAsynchronously(3, state -> loadFriendsAsync().thenApply(state::withFriends))
.then(4, PlayerDataState::buildProfile)
.asynchronously();
}
}
}Chainy uses Gradle to handle dependencies & building.
- Java 25 JDK or newer
- Git
- Gradlew installed
git clone https://github.com/einnxk/chainy.git
cd Chainy/
./gradlew clean buildChainy is licensed under the Apache 2 license. Please see the LICENSE for more info.