Reactive Programming on Android with RxJava


new Observer < String >() { 6 @Override 7 public



Download 1,47 Mb.
Pdf ko'rish
bet18/60
Sana20.04.2022
Hajmi1,47 Mb.
#566724
1   ...   14   15   16   17   18   19   20   21   ...   60
Bog'liq
reactiveandroid

new
Observer
<
String
>() {
6
@Override
7
public
void
onSubscribe
(
Disposable d
) {
8
}
9
10
@Override
11
public
void
onNext
(
String value
) {
12
Log
.
d
(
TAG
,
"onNext(): "
+
value
);
13
}
14
15
@Override
16
public
void
onError
(
Throwable e
) {
17
}
18
19
@Override
20
public
void
onComplete
() {
21
Log
.
d
(
TAG
,
"onComplete()"
);
22
}
23
});
24
Log
.
d
(
TAG
,
"After subscribing."
);
The above code snippet will display in the console:
1
Creating Observable
.
2
onNext
() -
test
3
onComplete
()
4
After subscribing
.
The resulting order of print statements is observed since RxJava does not specifically impose
asynchronous behavior. It is not opinionated about where the asychronicity originates unless it
is otherwise specified.


Chapter 2: RxJava Core Components
18
RxJava is synchronous by default. It is not opinionated about where asynchronicity
originates; it must be explicitly specified.
As you might guess, synchronous behavior may not be desired, and in many real-world cases, we
would want the underlying
Observable
to operate on a separate thread from the calling thread. The
power of RxJava lies in dealing with asynchronous streams, and we will look at how to do multi-
threading in RxJava in
. For now though, it is important to understand
that just because an
Observer
receives items via
push
does not mean that any sort of concurrency
is imposed.
RxJava also supports
pulling
from an
Observable
. Although this is not idiomatic RxJava, it was
included primarily for interoperability with codebases that aren’t 100% fully adapted to be reactive.
We will look at this more in

Download 1,47 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   ...   60




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish