Comments (5)
- No need to add
subscribeOn
on api call because it is already subscribe on io threads when retrofit initialized, here : https://github.com/rizmaulana/kotlin-mvvm-covid19/blob/master/app/src/main/java/id/rizmaulana/covid19/di/NetworkModule.kt
.addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io()))
- Actually we also no need
observeOn(schedulerProvider.ui())
becauseobserve
method on live data already force to running on main thread, we can see howobserve
method works here
@MainThread
public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<? super T> observer) {
assertMainThread("observe");
if (owner.getLifecycle().getCurrentState() == DESTROYED) {
// ignore
return;
}
LifecycleBoundObserver wrapper = new LifecycleBoundObserver(owner, observer);
ObserverWrapper existing = mObservers.putIfAbsent(observer, wrapper);
if (existing != null && !existing.isAttachedTo(owner)) {
throw new IllegalArgumentException("Cannot add the same observer"
+ " with different lifecycles");
}
if (existing != null) {
return;
}
owner.getLifecycle().addObserver(wrapper);
}
protected void postValue(T value) {
boolean postTask;
synchronized (mDataLock) {
postTask = mPendingData == NOT_SET;
mPendingData = value;
}
if (!postTask) {
return;
}
ArchTaskExecutor.getInstance().postToMainThread(mPostValueRunnable);
}
.subscribeOn(schedulerProvider.ui())
onDetailViewMode
: silly me 😅 it must be. observeOn(schedulerProvider.ui())
, but fortunately we use live data that makes view running on main thread. So it is not breaking.
But why it also not blocked the api call when subscribe onmainThread()
? AFAIK, RxJava only accepts firstsubscribeOn
declaration (which is already on io thread) so code.subscribeOn(schedulerProvider.ui())
is ignored, CMIIW
from kotlin-mvvm-covid19.
already test it, you can see the test case for DashboardViewModel, there's no issue for that
from kotlin-mvvm-covid19.
oh interesting, its very useful information, thanks
from kotlin-mvvm-covid19.
perhaps you can turn this issue thread into task to remove the confusing part @rizmaulana
from kotlin-mvvm-covid19.
and maybe schedulers wont be used in this scenario, how do we test? rxplugins if im not mistaken? itll be great if someone tries testing this @isfaaghyth
from kotlin-mvvm-covid19.
Related Issues (20)
- PlayStore Link Not working HOT 3
- Swipe To Refresh, Loading State, & ConnectionError State
- Markers Icon is not accurate HOT 1
- .idea should be ignored by git repo HOT 1
- App distribution HOT 9
- cant show maps HOT 2
- Showing a lot of - in full stats
- Impelement Indonesia details API HOT 3
- Replace google maps with mapbox or open maps HOT 4
- dynamic graph for total and delta data
- Distribute via F-Droid HOT 7
- Error Build HOT 2
- Recovered data always return 0
- yAxis Label Formatting in Total and Delta Daily Graph
- Default Region or country Pinned on start-up according localization
- cant see graph for country HOT 5
- Country data Change
- Thanks to contributors 🎉 HOT 1
- daily details list not working
- How to use the responseToResult method
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlin-mvvm-covid19.