centrifugal / centrifugal/centrifuge-java
Use Result type for returning success result or error
- Dominant language
- Java
- Stars
- 76
- Forks
- 38
- Avg merge
- 4h 18m
- Merged PRs (30d)
- 10
Description
Where we currently use `void onDone(@Nullable java.lang.Throwable e, @Nullable T result)`.
Similar to [Result](https://developer.apple.com/documentation/swift/result) type we use in our Swift SDK. Or similar to [kotlin.Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/).
In Java it may be sth like this:
```java
public class Result {
private T result;
private Throwable error;
private Result(T result, Throwable error) {
this.result = result;
this.error = error;
}
public static Result success(T result) {
return new Result<>(result, null);
}
public static Result error(Throwable error) {
return new Result<>(null, error);
}
public T getResult() {
return result;
}
public Throwable getError() {
return error;
}
public boolean isSuccess() {
return error == null;
}
public boolean isError() {
return error != null;
}
}
```
For now opened to collect opinions, unfortunately this will break API.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the current void onDone(@Nullable Throwable e, @Nullable T result) callback and inspecting all of its usages. The issue does not name files or tests; completion would require an agreed Result API design and migration of the affected callback surface, including its compatibility implications.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100