Combine: Asynchronous Programming with Swift. 3 Ed

Combine: Asynchronous Programming with Swift. 3 Ed

Combine: Asynchronous Programming with Swift. 3 Ed
Автор: Gardner Scott, Mishali Shai, Pillet Florent, Todorov Marin
Дата выхода: 2021
Издательство: Razeware LLC.
Количество страниц: 432
Размер файла: 3,0 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

 Book License

What You Need

Book Source Code & Forums

About the Authors

Acknowledgments

Chapter 1: Hello, Combine!

Asynchronous programming

Swift’s Modern Concurrency

Foundation of Combine

Combine basics

What’s the benefit of Combine code over “standard” code?

App architecture

Book projects

Key points

Where to go from here?

Chapter 2: Publishers & Subscribers

Getting started

Hello Publisher

Hello Subscriber

Hello Cancellable

Understanding what’s going on

Creating a custom subscriber

Hello Future

Hello Subject

Dynamically adjusting demand

Type erasure

Bridging Combine publishers to async/await

Challenge

Key points

Where to go from here?

Chapter 3: Transforming Operators

Getting started

Collecting values

Mapping values

Flattening publishers

Replacing upstream output

Incrementally transforming output

Challenge

Key points

Where to go from here?

Chapter 4: Filtering Operators

Getting started

Filtering basics

Compacting and ignoring

Finding values

Dropping values

Limiting values

Challenge

Key points

Where to go from here?

Chapter 5: Combining Operators

Getting started

Prepending

Appending

Advanced combining

Key points

Where to go from here?

Chapter 6: Time Manipulation Operators

Getting started

Shifting time

Collecting values

Collecting values (part 2)

Holding off on events

Timing out

Measuring time

Challenge

Key points

Where to go from here?

Chapter 7: Sequence Operators

Getting started

Finding values

Querying the publisher

Key points

Where to go from here?

Chapter 8: In Practice: Project "Collage Neue"

Getting started with “Collage Neue”

Presenting views

Wrapping a callback function as a future

Sharing subscriptions

Operators in practice

Challenges

Key points

Where to go from here?

Chapter 9: Networking

URLSession extensions

Codable support

Publishing network data to multiple subscribers

Key points

Where to go from here?

Chapter 10: Debugging

Printing events

Acting on events — performing side effects

Using the debugger as a last resort

Key points

Where to go from here?

Chapter 11: Timers

Using RunLoop

Using the Timer class

Using DispatchQueue

Key points

Where to go from here?

Chapter 12: Key-Value Observing

Introducing publisher(for:options:)

Preparing and subscribing to your own KVO-compliant properties

ObservableObject

Key points

Where to go from here?

Chapter 13: Resource Management

The share() operator

The multicast(_:) operator

Future

Key points

Where to go from here?

Chapter 14: In Practice: Project "News"

Getting started with the Hacker News API

Getting a single story

Multiple stories via merging publishers

Getting the latest stories

Challenges

Key points

Where to go from here?

Chapter 15: In Practice: Combine & SwiftUI

Hello, SwiftUI!

Getting started with “News”

A first taste of managing view state

Fetching the latest stories

Using ObservableObject for model types

Displaying errors

Subscribing to an external publisher

Initializing the app’s settings

Editing the keywords list

Challenges

Key points

Where to go from here?

Chapter 16: Error Handling

Getting started

Never

Dealing with failure

Key points

Where to go from here?

Chapter 17: Schedulers

An introduction to schedulers

Operators for scheduling

Scheduler implementations

Challenges

Key points

Where to go from here?

Chapter 18: Custom Publishers & Handling Backpressure

Creating your own publishers

Publishers as extension methods

The subscription mechanism

Publishers emitting values

Publishers transforming values

Handling backpressure

Key points

Where to go from here?

Chapter 19: Testing

Getting started

Testing Combine operators

Testing production code

Challenges

Key points

Where to go from here?

Chapter 20: In Practice: Building a Complete App

Getting started

Setting goals

Implementing JokesViewModel

Wiring JokesViewModel up to the UI

Implementing Core Data with Combine

Challenge

Key points

Where to go from here?

Conclusion

Writing asynchronous code can be challenging, with a variety of possible interfaces to represent, perform, and consume asynchronous work — delegates, notification center, KVO, closures, etc. Juggling all of these different mechanisms can be somewhat overwhelming. Does it have to be this hard? Not anymore!

In this book, you'll learn about Combine — Apple’s framework to work with asynchronous events in a unified and reactive way that ensures your app is always up to date based on the latest state of its data.

Who This Book Is For

This book is for intermediate iOS developers who already know the basics of iOS and Swift development but are interested in learning declarative/reactive programming and take their app and state management to the next level.

You'll also find this book interesting if you're interested in SwiftUI — as many of the reactive capabilities keeping your SwiftUI views up-to-date are built on top of Combine.

Topics Covered in Combine: Asynchronous Programming with Swift

  • What & Why: Learn what is Combine and reactive programming and the problems they solve, and how you can unify all of your asynchronous piece of work.
  • Operators: Learn how to compose, transform, filter and otherwise manipulate different pieces of asynchronous work using operators.
  • In Practice: You'll gain knowledge on various topics and techniques you'll leverage when writing your own real-life apps, as well as practice these techniques with actual hands-on apps and projects.
  • SwiftUI: You'll learn about how Combine is deeply rooted within SwiftUI and provides it with the ability to reactively update its views based on the state of your app.
  • Advanced Combine: Once you've got a handle on the basics, you'll dive into advanced Combine topics such as Error Handling, Schedulers, and Custom Publishers.

By the end of this book, you'll be a pro in building full-fledged applications using Combine's various abilities.


Похожее:

Список отзывов:

Нет отзывов к книге.