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

Homework RxJava Белянин Роман #51

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

Conversation

BelRom
Copy link

@BelRom BelRom commented May 1, 2022

Homework RxJava

import retrofit2.http.GET

interface CatsService {

@GET("random?animal_type=cat")
fun getCatFact(): Call<Fact>
fun getCatFact(): Flowable<Fact>

Choose a reason for hiding this comment

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

Flowable подразумевает что мы будем получать поток данных, в данном случае достаточно Single, но и Flowable и Observable - валидные типы для работы с запросами

return Flowable.empty()
return generateCatFact()
.repeatWhen { it.delay (2, TimeUnit.SECONDS) }
.distinct()

Choose a reason for hiding this comment

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

вот тут нужно быть аккуратнее, можно посмотреть марбл диаграмму в документации метода - distinct возвращает только уникальные элементы, т.е. в какой-то момент поток данных может прекратиться, когда мы пропушим весь список, лучше использовать distinctUntilChanged

Choose a reason for hiding this comment

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

можете попробовать перевести телефон/эмулятор в авиарежим, сразу будет понятен результат

@BelRom
Copy link
Author

BelRom commented May 7, 2022

Исправил

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