New Sample: Using Kotlin coroutines
See original GitHub issueI’d like to create a sample that demonstrates the power and elegance of Kotlin coroutines. It will use MVVM, Data Binding and Architecture Components (ViewModel and possibly LiveData). I plan to branch it off dev-todo-mvvm-live-kotlin
. The suggested new branch name is dev-todo-mvvm-live-kotlin-coroutines
.
The primary objective is to select and consistently apply a small subset of essential Kotlin coroutine idioms.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Coroutines basics - Kotlin
A coroutine is an instance of suspendable computation. It is conceptually similar to a thread, in the sense that it takes a block...
Read more >Kotlin Coroutines in Android - ProAndroidDev
The simplest way to create a coroutine is by calling the launch builder on a specified scope. It Launches a new coroutine without...
Read more >Introduction to Kotlin Coroutines - Baeldung
In this article, we'll be looking at coroutines from the Kotlin language. Simply put, coroutines allow us to create asynchronous programs in ......
Read more >domnikl/kotlin-coroutine-examples - GitHub
Kotlin coroutine examples. It attempts to explain various use-cases around coroutines in simple terms to explain them. concurrency: run multiple coroutines ...
Read more >Mastering Kotlin Coroutines - Amit Shekhar
The exact definition of Coroutines: A framework to manage concurrency in a more performant and simple way with its lightweight thread which is ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @dmytrodanylyk
I DISAGREE as it will lead to “leaking abstraction”. The Repository knows what it is doing and what kind of Dispatcher is required to do its work efficiently (CPU bound, I/O bound, long running, etc.). This knowledge should not be leaking to the ViewModel. I AGREE that hard-coding the Dispatcher is not ideal. The better option would be to inject it via the constructor, as we do with ViewModels.
There are no Job cancellations in this project. The reason is:
This is very different from MVP where the Presenter holds a reference to the View, so job cancellations become an important mechanism to avoid lifecycle related leaks and crashes.
@JoseAlcerreca @florina-muntenescu This Kotlin coroutine variant of
dev-todo-mvvm-live-kotlin
is COMPLETE. Could you please take a look? https://github.com/outware/android-architecture/tree/dev-todo-mvvm-live-kotlin-coroutinesI’ve noticed that the base app has been modified to use Room. Should this change be retrofitted into this variant as well?