Skip to content

Commit bb263a8

Browse files
authored
chore(velocity): better explain async handling (#717)
some users (2) came confused in the velocity channels because they didn't understand this example
1 parent 50b9219 commit bb263a8

File tree

1 file changed

+11
-1
lines changed
  • src/content/docs/velocity/dev/api

1 file changed

+11
-1
lines changed

src/content/docs/velocity/dev/api/event.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,17 @@ or add a second return an [`Continuation`](jd:velocity:com.velocitypowered.api.e
126126
```java
127127
@Subscribe(priority = 100)
128128
public void onLogin(LoginEvent event, Continuation continuation) {
129-
doSomeAsyncProcessing().addListener(continuation::resume, continuation::resumeWithException);
129+
doSomeAsyncProcessing().whenComplete((_, throwable) -> {
130+
if (throwable != null) {
131+
continuation.resumeWithException(throwable);
132+
} else {
133+
continuation.resume();
134+
}
135+
});
136+
}
137+
138+
private CompletableFuture<Void> doSomeAsyncProcessing() {
139+
//...
130140
}
131141

132142
@Subscribe(priority = 100)

0 commit comments

Comments
 (0)