doOnSubscribe is called on IO threaddoOnSubscribe gets called on main threadWhat is the difference between a process and a thread?“implements Runnable” vs “extends Thread” in JavaHow do I update the GUI from another thread?What is a daemon thread in Java?How to use threading in Python?Android “Only the original thread that created a view hierarchy can touch its views.”RxJava Observing on calling/subscribing threadSchedulers.io() not returning to main threadRxJava subscribeOn and observeOn not override the original Scheduler set before?Rxjava observeOn and subscribeOn in Retrofit
Lost Update Understanding
Carry vs Roll-Down on a zero-coupon IRS
Aesthetic proofs that involve Field Theory / Galois Theory
How to clarify between imagined sensations and "real" fantasy events?
Is there any relation/leak between two sections of LM358 op-amp?
How to say "cheat sheet" in French
Safe to use 220V electric clothes dryer when building has been bridged down to 110V?
Hilbert's hotel: why can't I repeat it infinitely many times?
Do wheelchair aircraft exist?
How do pilots align the HUD with their eyeballs?
Why solving a differentiated integral equation might eventually lead to erroneous solutions of the original problem?
Can anyone put a name to this Circle of Fifths observation?
Is it impolite to ask for an in-flight catalogue with no intention of buying?
Why does (inf + 0j)*1 evaluate to inf + nanj?
My manager quit. Should I agree to defer wage increase to accommodate budget concerns?
How can this Stack Exchange site have an animated favicon?
1, 2, 4, 8, 16, ... 33?
Hangman Game (YAHG)
Cut a cake into 3 equal portions with only a knife
Labview vs Matlab??Which one better for image processing?
Why does this image of Jupiter look so strange?
What exactly did this mechanic sabotage on the American Airlines 737, and how dangerous was it?
If an object moving in a circle experiences centripetal force, then doesn't it also experience centrifugal force, because of Newton's third law?
Should the average user with no special access rights be worried about SMS-based 2FA being theoretically interceptable?
doOnSubscribe is called on IO thread
doOnSubscribe gets called on main threadWhat is the difference between a process and a thread?“implements Runnable” vs “extends Thread” in JavaHow do I update the GUI from another thread?What is a daemon thread in Java?How to use threading in Python?Android “Only the original thread that created a view hierarchy can touch its views.”RxJava Observing on calling/subscribing threadSchedulers.io() not returning to main threadRxJava subscribeOn and observeOn not override the original Scheduler set before?Rxjava observeOn and subscribeOn in Retrofit
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have the following code:
checkZipCode.exec(it)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe
Timber.d("Main thread: $Looper.getMainLooper().isCurrentThread")
view.showLoading(true)
.doOnDispose view.showLoading(false)
.flatMapMaybe isZipValid ->
if (isZipValid)
userModel.zipCode = it.toString()
saveUser.exec(userModel)
autoSelectCityIfSingle.exec()
else
// TODO: Should show error here?
Maybe.empty()
.subscribe(...)
Logs are: Main thread: false
I thought that doOnSubscribe
is called on the latest scheduler above it. Isn't it?
android multithreading kotlin rx-java2
add a comment
|
I have the following code:
checkZipCode.exec(it)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe
Timber.d("Main thread: $Looper.getMainLooper().isCurrentThread")
view.showLoading(true)
.doOnDispose view.showLoading(false)
.flatMapMaybe isZipValid ->
if (isZipValid)
userModel.zipCode = it.toString()
saveUser.exec(userModel)
autoSelectCityIfSingle.exec()
else
// TODO: Should show error here?
Maybe.empty()
.subscribe(...)
Logs are: Main thread: false
I thought that doOnSubscribe
is called on the latest scheduler above it. Isn't it?
android multithreading kotlin rx-java2
add a comment
|
I have the following code:
checkZipCode.exec(it)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe
Timber.d("Main thread: $Looper.getMainLooper().isCurrentThread")
view.showLoading(true)
.doOnDispose view.showLoading(false)
.flatMapMaybe isZipValid ->
if (isZipValid)
userModel.zipCode = it.toString()
saveUser.exec(userModel)
autoSelectCityIfSingle.exec()
else
// TODO: Should show error here?
Maybe.empty()
.subscribe(...)
Logs are: Main thread: false
I thought that doOnSubscribe
is called on the latest scheduler above it. Isn't it?
android multithreading kotlin rx-java2
I have the following code:
checkZipCode.exec(it)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe
Timber.d("Main thread: $Looper.getMainLooper().isCurrentThread")
view.showLoading(true)
.doOnDispose view.showLoading(false)
.flatMapMaybe isZipValid ->
if (isZipValid)
userModel.zipCode = it.toString()
saveUser.exec(userModel)
autoSelectCityIfSingle.exec()
else
// TODO: Should show error here?
Maybe.empty()
.subscribe(...)
Logs are: Main thread: false
I thought that doOnSubscribe
is called on the latest scheduler above it. Isn't it?
android multithreading kotlin rx-java2
android multithreading kotlin rx-java2
edited Mar 28 at 17:18
Dr Mido
9456 silver badges35 bronze badges
9456 silver badges35 bronze badges
asked Mar 28 at 16:54
int_32int_32
5,88027 gold badges80 silver badges147 bronze badges
5,88027 gold badges80 silver badges147 bronze badges
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
The subscription execution path isn't really an emission that observeOn
acts upon. See
this question. If you really want to have something occur on the main thread in that spot in your chain, perhaps you can flatMap in another Observable
that would do something within its doOnSubscribe
(since that will occur on the emission thread, which is the main thread here).
add a comment
|
Well, doOnSubscribe
is executed on the same thread with subscribe()
.
I had problems because subscribe() was called on I/O thread.
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403050%2fdoonsubscribe-is-called-on-io-thread%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The subscription execution path isn't really an emission that observeOn
acts upon. See
this question. If you really want to have something occur on the main thread in that spot in your chain, perhaps you can flatMap in another Observable
that would do something within its doOnSubscribe
(since that will occur on the emission thread, which is the main thread here).
add a comment
|
The subscription execution path isn't really an emission that observeOn
acts upon. See
this question. If you really want to have something occur on the main thread in that spot in your chain, perhaps you can flatMap in another Observable
that would do something within its doOnSubscribe
(since that will occur on the emission thread, which is the main thread here).
add a comment
|
The subscription execution path isn't really an emission that observeOn
acts upon. See
this question. If you really want to have something occur on the main thread in that spot in your chain, perhaps you can flatMap in another Observable
that would do something within its doOnSubscribe
(since that will occur on the emission thread, which is the main thread here).
The subscription execution path isn't really an emission that observeOn
acts upon. See
this question. If you really want to have something occur on the main thread in that spot in your chain, perhaps you can flatMap in another Observable
that would do something within its doOnSubscribe
(since that will occur on the emission thread, which is the main thread here).
answered Mar 28 at 17:07
Justin BreitfellerJustin Breitfeller
12.1k4 gold badges34 silver badges47 bronze badges
12.1k4 gold badges34 silver badges47 bronze badges
add a comment
|
add a comment
|
Well, doOnSubscribe
is executed on the same thread with subscribe()
.
I had problems because subscribe() was called on I/O thread.
add a comment
|
Well, doOnSubscribe
is executed on the same thread with subscribe()
.
I had problems because subscribe() was called on I/O thread.
add a comment
|
Well, doOnSubscribe
is executed on the same thread with subscribe()
.
I had problems because subscribe() was called on I/O thread.
Well, doOnSubscribe
is executed on the same thread with subscribe()
.
I had problems because subscribe() was called on I/O thread.
answered Mar 28 at 17:39
int_32int_32
5,88027 gold badges80 silver badges147 bronze badges
5,88027 gold badges80 silver badges147 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403050%2fdoonsubscribe-is-called-on-io-thread%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown