Pass value from single across completable to result in rxjava AndroidStrange out of memory issue while loading an image to a Bitmap objectFling gesture detection on grid layoutHow do I pass data between Activities in Android application?How to pass an object from one activity to another on AndroidRxJava flat map: what happens when one of the resulting observable complete?RxJava2 Convert two Single's into CompletableRxjava observeOn and subscribeOn in RetrofitParallel api request using Single.zip not handling errorRxAndroid operator retryWhen is invoked but does not resubscribeObservable do not call onComplete (sqlbrite - mapToOneOrDefault)
Are there historical examples of audiences drawn to a work that was "so bad it's good"?
Why'd a rational buyer offer to buy with no conditions precedent?
Does water in vacuum form a solid shell or freeze solid?
How to deceive the MC
How does Dreadhorde Arcanist interact with split cards?
Why does the hash of infinity have the digits of π?
Can flying creatures choose to hover, even if they don't have hover in their flying speed?
What is the use case for non-breathable waterproof pants?
Are there any German nonsense poems (Jabberwocky)?
Why did other houses not demand this?
Cisco 3750X Power Cable
How to write numbers and percentage?
How does the Earth's center produce heat?
Why does the painters tape have to be blue?
If I arrive in the UK, and then head to mainland Europe, does my Schengen visa 90 day limit start when I arrived in the UK, or mainland Europe?
Can a UK national work as a paid shop assistant in the USA?
The disk image is 497GB smaller than the target device
What is to the west of Westeros?
Is there a simple example that empirical evidence is misleading?
Knight's Tour on a 7x7 Board starting from D5
Is it normal to "extract a paper" from a master thesis?
What did Brienne write about Jaime?
Quantum corrections to geometry
Unary Enumeration
Pass value from single across completable to result in rxjava Android
Strange out of memory issue while loading an image to a Bitmap objectFling gesture detection on grid layoutHow do I pass data between Activities in Android application?How to pass an object from one activity to another on AndroidRxJava flat map: what happens when one of the resulting observable complete?RxJava2 Convert two Single's into CompletableRxjava observeOn and subscribeOn in RetrofitParallel api request using Single.zip not handling errorRxAndroid operator retryWhen is invoked but does not resubscribeObservable do not call onComplete (sqlbrite - mapToOneOrDefault)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
This is what I want:
- Check if I have data about products in database.
- If I have data I run Single to get data from DB.
- If not I run Single for get data from backend
- If I get response I want to save data in DB using Completable.
- After saving data I want to map values from step 2 or 3 to view model
- In result I want to send data to activity.
This is what I have now:
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
Between flat map and map I need to run saveDataUseCase(it)
, but I don't know how to pass it
from completable to map. Any ideas?
android rx-java2
add a comment |
This is what I want:
- Check if I have data about products in database.
- If I have data I run Single to get data from DB.
- If not I run Single for get data from backend
- If I get response I want to save data in DB using Completable.
- After saving data I want to map values from step 2 or 3 to view model
- In result I want to send data to activity.
This is what I have now:
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
Between flat map and map I need to run saveDataUseCase(it)
, but I don't know how to pass it
from completable to map. Any ideas?
android rx-java2
add a comment |
This is what I want:
- Check if I have data about products in database.
- If I have data I run Single to get data from DB.
- If not I run Single for get data from backend
- If I get response I want to save data in DB using Completable.
- After saving data I want to map values from step 2 or 3 to view model
- In result I want to send data to activity.
This is what I have now:
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
Between flat map and map I need to run saveDataUseCase(it)
, but I don't know how to pass it
from completable to map. Any ideas?
android rx-java2
This is what I want:
- Check if I have data about products in database.
- If I have data I run Single to get data from DB.
- If not I run Single for get data from backend
- If I get response I want to save data in DB using Completable.
- After saving data I want to map values from step 2 or 3 to view model
- In result I want to send data to activity.
This is what I have now:
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
Between flat map and map I need to run saveDataUseCase(it)
, but I don't know how to pass it
from completable to map. Any ideas?
android rx-java2
android rx-java2
edited Mar 24 at 6:07
Tanveer Munir
1,7051422
1,7051422
asked Mar 23 at 21:40
edi233edi233
1,446103875
1,446103875
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
If your saveDataUseCase() is Completable then you can do this
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.faltMap
saveDataUseCase(it).toSingleDefault(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
But if you change return type of saveDataUseCase() to Unit, you can use Fred's answer. It would be better
add a comment |
Here I'd use doOnSuccess
. This seems ideal especially because you're creating a side effect, which we usually use the doOnXXX
methods for.
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.doOnSuccess
saveDataUseCase(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
The method will not change the result of the flatMap
so you will still get the correct object inside the map
function.
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/3.0/"u003ecc by-sa 3.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%2f55318661%2fpass-value-from-single-across-completable-to-result-in-rxjava-android%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
If your saveDataUseCase() is Completable then you can do this
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.faltMap
saveDataUseCase(it).toSingleDefault(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
But if you change return type of saveDataUseCase() to Unit, you can use Fred's answer. It would be better
add a comment |
If your saveDataUseCase() is Completable then you can do this
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.faltMap
saveDataUseCase(it).toSingleDefault(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
But if you change return type of saveDataUseCase() to Unit, you can use Fred's answer. It would be better
add a comment |
If your saveDataUseCase() is Completable then you can do this
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.faltMap
saveDataUseCase(it).toSingleDefault(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
But if you change return type of saveDataUseCase() to Unit, you can use Fred's answer. It would be better
If your saveDataUseCase() is Completable then you can do this
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.faltMap
saveDataUseCase(it).toSingleDefault(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
But if you change return type of saveDataUseCase() to Unit, you can use Fred's answer. It would be better
answered Mar 24 at 6:31
Andrey MatyushinAndrey Matyushin
363
363
add a comment |
add a comment |
Here I'd use doOnSuccess
. This seems ideal especially because you're creating a side effect, which we usually use the doOnXXX
methods for.
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.doOnSuccess
saveDataUseCase(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
The method will not change the result of the flatMap
so you will still get the correct object inside the map
function.
add a comment |
Here I'd use doOnSuccess
. This seems ideal especially because you're creating a side effect, which we usually use the doOnXXX
methods for.
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.doOnSuccess
saveDataUseCase(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
The method will not change the result of the flatMap
so you will still get the correct object inside the map
function.
add a comment |
Here I'd use doOnSuccess
. This seems ideal especially because you're creating a side effect, which we usually use the doOnXXX
methods for.
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.doOnSuccess
saveDataUseCase(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
The method will not change the result of the flatMap
so you will still get the correct object inside the map
function.
Here I'd use doOnSuccess
. This seems ideal especially because you're creating a side effect, which we usually use the doOnXXX
methods for.
checkProductsInDBUseCase.run()
.flatMap
if (it)
getProductsFromDBUseCase.run()
else
getProductsUseCase.run(3)
.doOnSuccess
saveDataUseCase(it)
.map
it.products.map item -> item.toViewModel()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onSuccess =
view.showBikes(it)
,
onError =
view.showBikesError(it.message.toString())
).addTo(disposables)
The method will not change the result of the flatMap
so you will still get the correct object inside the map
function.
answered Mar 24 at 3:15
FredFred
9,18012846
9,18012846
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%2f55318661%2fpass-value-from-single-across-completable-to-result-in-rxjava-android%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