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

Rx Homework #52

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Rx Homework #52

wants to merge 4 commits into from

Conversation

yeliseyL
Copy link

@yeliseyL yeliseyL commented May 2, 2022

No description provided.

catsService.getCatFact()
.subscribeOn(Schedulers.io())
.onErrorResumeNext(localCatFactsGenerator.generateCatFact())
.delay(2000, TimeUnit.MILLISECONDS)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут есть проблема, что если перевести девайс в авиа режим то берется только один факт из локального списка и обновление прекращается, а должны продолжать обновляться каждые 2 секунды

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

@@ -25,6 +28,9 @@ class LocalCatFactsGenerator(
*/
fun generateCatFactPeriodically(): Flowable<Fact> {
val success = Fact(context.resources.getStringArray(R.array.local_cat_facts)[Random.nextInt(5)])
return Flowable.empty()
return Flowable.create<Fact?>( { emitter ->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут получается мы создаем поток данных один раз берем факт о коте, засыпаем на две секунды и больше ничего не происходит, можно посмотреть в сторону Flowable.interval()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

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.

2 participants