android / android/nowinandroid

Rename `Result` to `TaskState`

Open
#1,366 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
21.8k
Forks
4.6k
Avg merge
19h 20m
Merged PRs (30d)
2

Description

`Loading` is a state, not a result. Result means an outcome. Something's outcome is always either `Success` or `Failure`. A `Failure` is **caused by** an error (a.k.a. `Throwable`).

A **task** can be in one of the following **states**;
- Not Started _(not useful)_
- Ongoing/In Progress
- Ended (either successfully or unsuccessfully)

A result of a task is also one of its states (Ended). Because of that, `Success` and `Failure` can easily be incorporated into `TakState`.

In the end, what we get is:

```kt
sealed interface TaskState {
data class Success(val data: T) : TaskState
data class Failure(val cause: Throwable) : TaskState
data object Ongoing : TaskState
}
```


If this is acceptable, let me know, I'll open a PR.

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by locating references to Result, Loading, Success, and Failure, then compare their current usage with the proposed TaskState model. Done would require an agreed design and consistent updates across the affected code and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.