Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove withContext, refactor duplicate methods #907

Merged
merged 2 commits into from
Feb 28, 2023

Conversation

dturner
Copy link
Collaborator

@dturner dturner commented Feb 27, 2023

Here's what I've done and why:

  • Removed all instances of withContext. withContext requires the caller to know something about the execution of the enclosed method(s) (e.g. it is cpu or disk bound). In this case, these calls are redundant because the only I/O bound operations are handled by Room, which will already move those operations onto the I/O thread, so we don't need to be concerned with it.
  • Removed the completeTask(task: Task) and activateTask(task: Task) methods in favour of using the existing completeTask(taskId: String) and activateTask(taskId: String). This creates a smaller API surface which is more loosely coupled.
  • Refactored Task to be immutable. Having a mutable model is an anti-pattern as it allows callers to modify the model, which violates SSOT.

@dturner dturner merged commit 17da41e into android:main Feb 28, 2023
@dturner dturner deleted the remove-withcontext branch February 28, 2023 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants