-
Notifications
You must be signed in to change notification settings - Fork 196
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
base: master
Are you sure you want to change the base?
Conversation
import retrofit2.http.GET | ||
|
||
interface CatsService { | ||
|
||
@GET("random?animal_type=cat") | ||
fun getCatFact(): Call<Fact> | ||
fun getCatFact(): Flowable<Fact> |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот тут нужно быть аккуратнее, можно посмотреть марбл диаграмму в документации метода - distinct возвращает только уникальные элементы, т.е. в какой-то момент поток данных может прекратиться, когда мы пропушим весь список, лучше использовать distinctUntilChanged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можете попробовать перевести телефон/эмулятор в авиарежим, сразу будет понятен результат
Исправил |
Homework RxJava