[Ebooks PDF] download Asynchronous Programming with SwiftUI and Combine: Functional Programming to Build UIs on Apple Platforms 1st Edition Peter Friese full chapters
[Ebooks PDF] download Asynchronous Programming with SwiftUI and Combine: Functional Programming to Build UIs on Apple Platforms 1st Edition Peter Friese full chapters
com
https://ebookmass.com/product/asynchronous-programming-with-
swiftui-and-combine-functional-programming-to-build-uis-on-
apple-platforms-1st-edition-peter-friese/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmass.com/product/asynchronous-programming-with-swiftui-
and-combine-1st-edition-peter-friese/
ebookmass.com
https://ebookmass.com/product/mastering-functional-programming-with-
python-brett-neutreon/
ebookmass.com
https://ebookmass.com/product/asynchronous-programming-in-rust-1st-
edition-carl-fredrik-samson/
ebookmass.com
https://ebookmass.com/product/modern-concurrency-on-apple-platforms-
using-async-await-with-swift-1st-edition-andres-ibanez-kautsch/
ebookmass.com
Simple and Efficient Programming with C#: Skills to Build
Applications with Visual Studio and .NET 2nd Edition
Vaskaran Sarcar
https://ebookmass.com/product/simple-and-efficient-programming-with-c-
skills-to-build-applications-with-visual-studio-and-net-2nd-edition-
vaskaran-sarcar/
ebookmass.com
https://ebookmass.com/product/introducing-rescript-functional-
programming-for-web-applications-1st-edition-danny-yang/
ebookmass.com
https://ebookmass.com/product/an-introduction-to-parallel-programming-
second-edition-peter-s-pacheco/
ebookmass.com
Peter Friese
Asynchronous Programming with SwiftUI and Combine: Functional
Programming to Build UIs on Apple Platforms
Peter Friese
Hamburg, Germany
Foreword������������������������������������������������������������������������������������������xvii
Preface����������������������������������������������������������������������������������������������xix
Acknowledgments�����������������������������������������������������������������������������xxi
Part 1�������������������������������������������������������������������������������������������1
Chapter 1: SwiftUI: A New Beginning���������������������������������������������������3
Why a New UI Framework?�����������������������������������������������������������������������������������5
SwiftUI Principles��������������������������������������������������������������������������������������������������7
Declarative vs. Imperative�������������������������������������������������������������������������������7
State Management������������������������������������������������������������������������������������������8
Composition over Inheritance��������������������������������������������������������������������������9
Everything Is a View—Except That It Isn’t�����������������������������������������������������10
UIs Are a Function of Their State�������������������������������������������������������������������10
A Quick Tour of SwiftUI����������������������������������������������������������������������������������������11
Prerequisites�������������������������������������������������������������������������������������������������11
Creating a New SwiftUI App��������������������������������������������������������������������������11
Adding Some Interaction to Your App������������������������������������������������������������19
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
Styling���������������������������������������������������������������������������������������������������������������134
List Styles����������������������������������������������������������������������������������������������������135
Headers and Footers�����������������������������������������������������������������������������������137
List Cells������������������������������������������������������������������������������������������������������139
Separators���������������������������������������������������������������������������������������������������140
Actions��������������������������������������������������������������������������������������������������������������143
Swipe-to-Delete������������������������������������������������������������������������������������������144
Moving and Deleting Items Using EditMode������������������������������������������������145
Swipe Actions����������������������������������������������������������������������������������������������147
Managing Focus in Lists�����������������������������������������������������������������������������������154
How to Manage Focus in SwiftUI�����������������������������������������������������������������154
How to Manage Focus in Lists���������������������������������������������������������������������156
Handling the Enter Key��������������������������������������������������������������������������������158
What About MVVM?�������������������������������������������������������������������������������������159
Eliminating Empty Elements������������������������������������������������������������������������163
Summary����������������������������������������������������������������������������������������������������������165
viii
Table of Contents
Part 2���������������������������������������������������������������������������������������205
Chapter 7: Getting Started with Combine�����������������������������������������207
What Is Functional Reactive Programming?�����������������������������������������������������207
Publishers���������������������������������������������������������������������������������������������������������209
Subscribers�������������������������������������������������������������������������������������������������������211
Operators����������������������������������������������������������������������������������������������������������213
Composing Operators���������������������������������������������������������������������������������������215
Combining Publishers���������������������������������������������������������������������������������������220
Summary����������������������������������������������������������������������������������������������������������223
ix
Table of Contents
x
Table of Contents
xi
Table of Contents
Part 3���������������������������������������������������������������������������������������361
Chapter 14: Getting Started with async/await���������������������������������363
Synchronous Programming with Functions������������������������������������������������������367
Asynchronous Programming with Closures������������������������������������������������������371
Asynchronous Programming with async/await������������������������������������������������377
Defining and Calling Asynchronous Functions��������������������������������������������377
Calling Asynchronous Functions in Parallel�������������������������������������������������381
Summary����������������������������������������������������������������������������������������������������������383
xii
Table of Contents
Index�������������������������������������������������������������������������������������������������423
xiii
About the Author
Peter Friese is a software engineer with over
30 years of experience in building software for
a wide range of platforms—from Windows,
J2EE, the Web, Android, to iOS and the Mac. He
works as a Senior Developer Advocate on the
Firebase team at Google, where he is in charge
of making sure iOS developer have a great
experience using the Firebase SDK on iOS and
Apple’s other platforms.
Peter writes about SwiftUI, Swift, and Firebase development on his
blog, peterfriese.dev, and can be found on Twitter as @peterfriese.
xv
Foreword
I’ve been developing iOS apps for a while and started learning SwiftUI
almost as soon as it was released back in 2019. I remember that I couldn’t
wait to start using it because it just seemed so much more intuitive for me
than UIKit.
There wasn’t much SwiftUI documentation at first and those of us who
jumped straight in had to figure out a lot of things for ourselves. So I started
sharing what I learned while building apps with SwiftUI on a blog.
Just a few months later, the SwiftUI team at Apple reached out to me to
join them in working on the framework. It was an invaluable experience
and it gave me a great perspective on the inner workings of SwiftUI and
the decisions behind the APIs. Sure, SwiftUI is not perfect and still needs
time to mature, but it’s already making many developers happier and more
excited about building apps for Apple platforms. A lot of thought goes into
making SwiftUI APIs as simple and as streamlined as they are, so that we
can get the right behavior for the platform by default.
I left Apple in April 2022 and joined Nil Coalescing as a cofounder and
a software engineer. Though I’m a little sad that I don’t get to contribute
to the SwiftUI framework directly anymore, I’m really happy that I’m
now able to use the APIs I helped to develop and to share my SwiftUI
knowledge with other iOS developers.
Seeing how much Apple is betting on SwiftUI by introducing new
frameworks that require using it like WidgetKit and Swift Charts, I believe
it has a great potential. It’s also nice to see how many more developers are
starting to use SwiftUI and how much more great SwiftUI-related content is
now available both from Apple and from the community.
xvii
Discovering Diverse Content Through
Random Scribd Documents
Such as will join their profit with their pleasure,
And come to feed their understanding parts;—
For these I'll prodigally spend myself,
And speak away my spirit into air;
For these I'll melt my brain into invention,
Coin new conceits, and hang my richest words
As polished jewels in their bounteous ears.5
5 BEN JONSON.
Such readers, they who to their learning add knowledge, and to their
knowledge wisdom and to their wisdom benevolence, will say to me
But such readers are very few. Walter Landor said that if ten such
persons should approve his writings, he would call for a division and
count a majority. To please them is to obtain an earnest of enduring
fame; for which, if it be worth any thing, no price can be too great.
But for the aggregate any thing is good enough. Yes my Public, Mr.
Hume's arithmetic and Mr. Brougham's logic, Lord Castlereagh's
syntax, Mr. Irving's religion and Mr. Carlisle's irreligion, the politics of
the Edinburgh Review and the criticism of the Quarterly, Thames
water, Brewer's beer, Spanish loans, old jokes, new constitutions,
Irish eloquence, Scotch metaphysics, Tom and Jerry, Zimmerman on
Solitude, Chancery Equity and Old Bailey Law, Parliamentary wit, the
patriotism of a Whig Borough-monger, and the consistency of a
British cabinet; Et s'il y a encore quelque chose à dire, je le tiens
pour dit;—
6 ARISTOPHANES.
Yes my Public,
7 BEN JONSON.
INTERCHAPTER XXII.
VARIETY OF STILES.
Stiles may with more accuracy be classed, and for this purpose
metals might be used in literature as they are in heraldry. We might
speak of the golden stile, the silver, the iron, the leaden, the
pinchbeck and the bronze.
The flatulent stile, the feverish, the aguish, and the atrabilious are all
as common as the diseases of body from which they take their
name, and of mind in which they originate; and not less common
than either is the dyspeptic stile, proceeding from a weakness in the
digestive faculty.
Ἐγὼ δ᾽ οὖν καὶ αὐτὸς, ὦ Αντιφῶν, ὥσπερ ἄλλός τις ἢ ἵππῳ ἀγαθῷ ἢ
κυνὶ ἢ ὂρνιθι ἥδεται, οὕτω καὶ ἒτι μᾶλλον ἥδομαι τοῖς φίλοις ἀγαθοῖς·
καὶ, ἐάν τι σχῶ ἀγαθὸν διδάσκω, καὶ ἄλλοις σύνιστημι, παρ᾽ ὧν ἂν
ἡγῶμαι ὠφελήσεσθαί τι αὐτοὺς εἰς ἀρετήν᾽ καὶ, τοὺς θησαυροὺς τῶν
πάλι σοφῶν ἀνδρῶν, οὕς ἐκεῖνοι κατέλιπον ἐν βιβλίοις γράφεντες,
ἀνελίττων κοινῆ σὺν τοῖς φίλοις διέρχομαι· καὶ ἄν τι ὁρῶμεν ἀγαθὸν,
ἐκλεγόμεθα, καὶ μέγα νομίζομεν κέρδος, ἐὰν ἀλλήλοις ὠφέλιμοι
γιγνώμεθα.
INTERCHAPTER XXIII.
No man is so foolish, but may give another good counsel sometimes; and no man is
so wise, but may easily err, if he will take no other counsel but his own.
BEN JONSON.
And who, the Devil, are you exclaims that reader, who are
impertinent enough to offer your advice, and fool enough to suppose
that I shall listen to it?
You are again reprimanded Sir. If it be a bad thing to have the Devil
at one's elbow, it cannot be a good one to have him at ones
tongue's end. The sentence is sufficiently applicable. It is a humane
thing to offer advice where it is wanted, and a very humane thing to
write and publish a book which is intended to be either useful or
delightful to those who read it.
What you are pleased to call by that name, Mr. Reader, may be
either sense or nonsense according to the understanding which it
meets with. Quicquid recipitur, recipitur in modum recipientis. Look
in the seventh Chapter of the second book of Esdras, and at the
twenty-fifth verse you will find the solution of your demand.
And do you suppose I shall take the trouble of looking into the Bible
to please the humour of such a fellow as you?
If you do not, Sir, there are others who will; and more good may
arise from looking into that book,—even upon such an occasion,—
than either they or I can anticipate.
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookmass.com