Reactive Programming with Kotlin Learn Rx with RxJava RxKotlin and RxAndroid 2nd Edition Raywenderlich Tutorial Team & Alex Sullivan download
Reactive Programming with Kotlin Learn Rx with RxJava RxKotlin and RxAndroid 2nd Edition Raywenderlich Tutorial Team & Alex Sullivan download
https://ebookmeta.com/product/real-world-android-by-tutorials-
second-edition-professional-app-development-with-kotlin-
raywenderlich-tutorial-team/
https://ebookmeta.com/product/rxswift-reactive-programming-with-
swift-second-edition-raywenderlich-com-team/
https://ebookmeta.com/product/flutter-apprentice-first-edition-
learn-to-build-cross-platform-apps-raywenderlich-tutorial-team/
https://ebookmeta.com/product/imagine-a-vision-for-christians-in-
the-arts-steve-turner/
The Plant Contract Art s Return to Vegetal Life 1st
Edition Prudence Gibson
https://ebookmeta.com/product/the-plant-contract-art-s-return-to-
vegetal-life-1st-edition-prudence-gibson/
https://ebookmeta.com/product/the-two-faces-of-democracy-
decentering-agonism-and-deliberation-mary-f-scudder/
https://ebookmeta.com/product/cricket-radio-tuning-in-the-night-
singing-insects-1st-edition-john-himmelman/
https://ebookmeta.com/product/chasing-the-chinese-dream-four-
decades-of-following-china-s-war-on-poverty-1st-edition-william-
n-brown/
https://ebookmeta.com/product/bifurcate-there-is-no-
alternative-1st-edition-bernard-stiegler-and-the-international-
collective-eds/
Exhibitions for Social Justice 1st Edition Elena
Gonzales
https://ebookmeta.com/product/exhibitions-for-social-justice-1st-
edition-elena-gonzales/
Reactive Programming with Kotlin
Notice of Rights
All rights reserved. No part of this book or corresponding materials (such as text,
images, or source code) may be reproduced or distributed by any means without prior
written permission of the copyright owner.
Notice of Liability
This book and all corresponding materials (such as source code) are provided on an
“as is” basis, without warranty of any kind, express of implied, including but not
limited to the warranties of merchantability, fitness for a particular purpose, and
noninfringement. In no event shall the authors or copyright holders be liable for any
claim, damages or other liability, whether in action of contract, tort or otherwise,
arising from, out of or in connection with the software or the use of other dealing in
the software.
Trademarks
All trademarks and registered trademarks appearing in this book are the property of
their own respective owners.
raywenderlich.com 2
Reactive Programming with Kotlin
Dedications
"To my wonderful partner Pallavi, without whom I would have
never been able to start this undertaking. Your support and
encouragement mean the world to me."
— Alex Sullivan
raywenderlich.com 3
Reactive Programming with Kotlin
raywenderlich.com 4
Reactive Programming with Kotlin
Matei Suica is the final pass editor for this book. Matei is a
software developer that dreams about changing the world with his
work. From his small office in Romania, Matei is always trying to
work on Apps that will help millions. When the laptop lid closes, he
likes to read and go to the gym. You can find him on Twitter:
@mateisuica
raywenderlich.com 5
Reactive Programming with Kotlin
Acknowledgments
We'd also like to thank the RxSwift: Reactive Programming with Swift authors, whose
work served as the basis for parts of this book:
• Scott Gardner has been developing iOS apps since 2010, Swift since the day it was
announced, and RxSwift since before version 1. He's authored several video
courses, tutorials, and articles on iOS app development, presented at numerous
conferences, meetups, and online events, and this is his second book. Say hello to
Scott on Twitter at @scotteg.
• Junior Bontognali has been developing on iOS since the first iPhone and joined
the RxSwift team in the early development stage. Based in Switzerland, when he's
not eating cheese or chocolate, he's doing some cool stuff in the mobile space,
without denying to work on other technologies. Other than that he organizes tech
events, speaks and blogs. Say hello to Junior on Twitter at @bontoJR.
• Florent Pillet has been developing for mobile platforms since the last century and
moved to iOS on day 1. He adopted reactive programming before Swift was
announced and has been using RxSwift in production since 2015. A freelance
developer, Florent also uses Rx on Android and likes working on tools for
developers like the popular NSLogger when he's not contracting for clients
worldwide. Say hello to Florent on Twitter at @fpillet.
• Marin Todorov is one of the founding members of the raywenderlich.com team
and has worked on seven of the team's books. Besides crafting code, Marin also
enjoys blogging, teaching, and speaking at conferences. He happily open-sources
code. You can find out more about Marin at www.underplot.com.
raywenderlich.com 6
Reactive Programming with Kotlin
raywenderlich.com 7
Reactive Programming with Kotlin
raywenderlich.com 8
Reactive Programming with Kotlin
raywenderlich.com 9
Reactive Programming with Kotlin
Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Chapter 3: Subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
What are subjects? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Working with publish subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Working with behavior subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Working with replay subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Working with async subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Working with the RxRelay library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Where to go from here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Chapter 4: Observables & Subjects in Practice . . . . . . . . . . . . . . 83
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Using a BehaviorSubject in a ViewModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Adding photos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Communicating with other views via subjects. . . . . . . . . . . . . . . . . . . . . . . . 92
Creating a custom observable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Review: Single, Maybe, Completable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Using Single in the app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
raywenderlich.com 10
Reactive Programming with Kotlin
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Chapter 6: Filtering Operators in Practice . . . . . . . . . . . . . . . . . 126
Improving the Combinestagram project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Chapter 7: Transforming Operators . . . . . . . . . . . . . . . . . . . . . . . . 141
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Transforming elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Transforming inner observables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Observing events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Chapter 8: Transforming Operators in Practice . . . . . . . . . . . . 158
Getting started with GitFeed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Fetching data from the web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Transforming the response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Processing the response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Persisting objects to disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Adding a last-modified header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Challenge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Key points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Chapter 9: Combining Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Prefixing and concatenating. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Merging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
raywenderlich.com 11
Reactive Programming with Kotlin
raywenderlich.com 12
Reactive Programming with Kotlin
raywenderlich.com 13
Reactive Programming with Kotlin
raywenderlich.com 14
Reactive Programming with Kotlin
raywenderlich.com 15
Discovering Diverse Content Through
Random Scribd Documents
that he was in possession of documents to substantiate the fact;
but, to my surprise, instead of such documents, he has adduced and
principally relied on the constitution, in which there is not a single
imperative sentence obligatory on Congress, either to receive a
cession, or, when received, to continue exclusive jurisdiction over
one foot of territory—the plain and unequivocal language of the
constitution leaving it perfectly optional whether to receive, and, if
received, whether to retain jurisdiction or not. Hence, I conceive that
no legislative body can be justly charged with tyranny or oppression
for altering or (if from experience it becomes necessary) disannulling
their own acts—a contra-opinion I consider as altogether
uncongenial to improvement, genuine liberty, and the inherent rights
of man, and as such, I hope will ever be exploded in these United
States.
Wednesday, January 9.
District of Columbia.
District of Columbia.
The bill to prohibit the exaction of bail upon certain suits within
the District of Columbia was brought in engrossed, and read the
third time.
The final passage of the bill was opposed by Mr. Goddard, Mr. Root,
and Mr. Nelson, and defended by Mr. Newton, as a proper measure to
prevent the oppression of malignant creditors.
Mr. Eppes desired Mr. Beckley to read that part of the Constitution of
the United States relative to the extent of the Judiciary power, and
that part of the law establishing the Judicial authority of the District
of Columbia, with a view of showing that the bill was not essentially
necessary.
Mr. Early moved a recommitment of the bill to a select committee.
Mr. Bedinger wished that the bill might go to a select committee,
because he considered the principle a valuable one. He imagined,
however, that the details were not altogether perfect. He felt
concerned on this subject, on account of several of his constituents
who had been tricked out of notes and bonds for lands in Kentucky,
which had been advertised, and were no longer available against the
drawers in that State; but, should it so happen that business called
them to Washington, they might be extremely harassed for want of
bail.
The reference was opposed by Mr. R. Griswold, as he was against
the principle of the bill altogether.
On the question to recommit it, it passed in the negative—ayes
44, noes 59.
The question was then taken on the passage of the bill, and it was
lost, there being but thirty members who voted in its favor.
DIVORCES.
Resolved, That, from and after the fourth of July, 1805, all blacks
and people of color that shall be born within the District of Columbia,
or whose mother shall be the property of any person residing within
the said district, shall be free, the males at the age of ——, and the
females at the age of ——.
The Speaker laid before the House a letter from the Secretary of
State, accompanying statements and abstracts relative “to the
number of American seamen who have been impressed or detained
on board of the ships of war of any foreign nation; with the names
of the persons impressed; the name of the ship or vessel by which
they were impressed; the nation to which she belonged, and the
time of the impressment; as also certain facts and circumstances
relating to the same;” prepared in obedience to a resolution of this
House of the thirty-first ultimo.
Mr. Crowninshield said, that the list of impressed seamen, furnished
by the Secretary of State, exceeded in number any thing he had
expected. He thought these impressments ought to be prevented,
and that the subject demanded investigation. He had drafted a
resolution, which he would submit to the House, having in view to
connect this with another very important subject. Many gentlemen
must have observed that some late proclamations had been issued
by the Governors of the several British West India Islands,
interdicting the American trade after May next. The proclamations
bore date in October or November, and were to take effect in six
months. It appeared to him that the British Government were
determined to exclude us from their islands, upon the expectation
that their own vessels would be competent to carry the necessary
supplies. Mr. C. said we had a right to carry the productions of the
United States in American bottoms, and he hoped we should never
permit foreign ships to come to our ports and carry on an exclusive
trade with any country whatever, where our vessels were not
allowed the same privilege. His intention was to prevent the
American carrying trade to the West Indies from falling into the
hands of other nations. He would not exclude foreign vessels from
our ports, but it was desirable that our own export trade should not
be monopolized by foreigners. The subject was highly important to
this country. Will the United States tamely submit to see some of its
best citizens torn from their families and friends, without attempting
something for their relief? Shall we see another country pursuing
measures hostile to our commercial rights and make no effort to
correct the mischief? The West India Islands depended on the
United States for their ordinary supplies, and our vessels had usually
carried a large proportion of their cargoes on American account; but
it appeared now that we were to be shut out from this trade, and it
was in future to be carried on in foreign vessels. An effectual remedy
would be to prohibit the exportation of our productions in foreign
bottoms to all ports of islands with which we were not permitted to
have intercourse, and in order that the subject might undergo the
examination which its importance demanded, he offered the
following resolution:
Georgia Claims.
Mr. Dana moved that the committee rise and report the resolution.
Mr. J. Randolph wished, before the committee rose, that the
gentleman from Connecticut (Mr. Dana) would assign some reasons
for the adoption of the resolution. No two things could be more
opposite than the prefatory statement made by the Committee of
Claims and the resolution which terminated the report. As there
were no reasons assigned, he suspected the gentleman had kept
them back with a view of surprising the House by their novelty; but
he hoped the committee would not agree to the motion, unless
some better cause was assigned for its adoption than had hitherto
been made known.
Mr. Dana said the Committee of Claims, in the report now before
the Committee of the Whole, had confined themselves to a
statement of facts derived from the documents referred to them. He
conceived it to be the business of the Committee of Claims to
investigate the facts, and arrange them in such a manner as to free
the House from the labor of detail; they had done this, and the
report was a summary of all that passed in review before them. It
was left to gentlemen to reason on the case according to their
course of reflection. Whether the committee reasoned on the subject
well or ill, he did not know that gentlemen were bound to follow
them in their conclusion. Indeed, he apprehended that were the
reasoning ever so energetic, it would not go to satisfy every
gentleman. On a question like the present, he despaired of making it
satisfactory to the gentleman who had asked for reasons. He was
persuaded that gentleman could not be convinced by any argument
the committee might have used, and it was idle to call upon them to
perform impossibilities.
The question on the committee’s rising and reporting their
agreement to the resolution was put, and carried—yeas 61, nays 50.
The Speaker having resumed the chair, Mr. Varnum reported the
foregoing resolution as agreed to.
Mr. Bryan called for the reading of that rule of the House which
restrains interested persons from voting.
The Clerk read the same, as follows:
Georgia Claims.