SlideShare a Scribd company logo
Introduction of Apple’s
exciting new framework
Combine
Imperative vs Declarative
Telling the machine how to do something and as a result what you want to happen
will happen.
Telling a machine what would like to happen and let the computer figure how to do
it!
Combine in iOS - Basics
Async in Swift
Grand Central Dispatch
NSOperationQueue
POSIX Threads
Target / Action
Callbacks / Completion Handlers
Some factors about async in swift
Hard to understand
More manual effort
Callback hell
Hard to maintain
Reactive Programming, which focuses on asynchronous data streams, which you
can listen to and react accordingly.
Functional Programming, which emphasizes calculations via mathematical-style
functions, immutability and expressiveness, and minimizes the use of variables
and state.
FRP is the combination of functional and reactive paradigms. In other words, it is
reacting to data streams using the functional paradigm.
Eg: RxSwift, ReactiveSwift
Functional Reactive Programming
What is Combine?
Combine is a new reactive framework created by Apple that streamlines how you
can process asynchronous operations.
Combine code is declarative and succinct, making it easy to write and read once
you have a basic understanding of it.
Combine also allows you to neatly organize related code in one place instead of
having that code spread out across multiple files.
Publisher
The essence of Combine is: publishers send values to subscribers.
To become a publisher, a type must adopt and conform to the Publisher protocol,
which includes the following:
associatedtype Output
associatedtype Failure : Error
Specifically, a publisher must define the type of values it will send, and its failure
error type or Never if it will never send an error.
How to create publishers
Combine is integrated throughout the iOS SDK and Swift standard library.
For example, this enables us to create a publisher from a
NotificationCenter.Notification, or even an array of primitive values.
Subscriber
A subscriber attaches to a publisher to receive values from it.
And the process is called Subscription.
Subscribers must adopt and conform to the Subscriber protocol, which includes
the following:
associatedtype Input
associatedtype Failure: Error
How to create subscription
There are two ways to create a subscription to a publisher:
● By using one of the sink operators.
● By using one of the assign(to:on:) operators.
Example Usecase 1
Chaining Asynchronous Calls
Example Usecase 2
Performing Multiple Asynchronous Calls
Example Usecase 3
Merges Two Notifications and maps them
How to stop subscriptions
There are two ways to stop subscriptions:
● Call cancel() on a subscription token.
● Do nothing and let normal memory management rules to apply, i.e., the token
or collection of AnyCancellable will call cancel() on the subscriptions upon
deinitialization.
Combine in iOS - Basics
Major advantages
Combine is integrated into many existing frameworks in iOS, macOS, watchOS,
and tvOS.
SwiftUI that relies heavily on Combine.
The Foundation framework contains a lot of extensions to work with Combine.
It allows to work with common types we are already familiar with:
● A URLSessionTask Publisher that publishes the data response or request
error
● Operators for easy JSON decoding
● A Publisher for a specific Notification.Name that publishes the notification
Combine
Combine
Deployment Target iOS 13.0+
Platforms supported iOS, macOS, tvOS,
watchOS
Spec Reactive Streams (+
adjustments)
Framework Consumption First-party (built-in)
Maintained by Apple
UI Bindings SwiftUI
Thank you
Ad

More Related Content

What's hot (20)

【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
NGINX, Inc.
 
Spring cloud
Spring cloudSpring cloud
Spring cloud
Milan Ashara
 
平成26年度 滋賀県土地家屋調査士会研修会:「QGISを利用した幾何補正手法の習得」講師,大津地方法務局(滋賀県大津市),2014年11月10日.
平成26年度 滋賀県土地家屋調査士会研修会:「QGISを利用した幾何補正手法の習得」講師,大津地方法務局(滋賀県大津市),2014年11月10日.平成26年度 滋賀県土地家屋調査士会研修会:「QGISを利用した幾何補正手法の習得」講師,大津地方法務局(滋賀県大津市),2014年11月10日.
平成26年度 滋賀県土地家屋調査士会研修会:「QGISを利用した幾何補正手法の習得」講師,大津地方法務局(滋賀県大津市),2014年11月10日.
和人 青木
 
ホットペッパービューティーにおけるモバイルアプリ向けAPIのBFF/Backend分割
ホットペッパービューティーにおけるモバイルアプリ向けAPIのBFF/Backend分割ホットペッパービューティーにおけるモバイルアプリ向けAPIのBFF/Backend分割
ホットペッパービューティーにおけるモバイルアプリ向けAPIのBFF/Backend分割
Recruit Lifestyle Co., Ltd.
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
ModusJesus
 
SPARQL入門
SPARQL入門SPARQL入門
SPARQL入門
Takeshi Mikami
 
Introduction to Ionic framework
Introduction to Ionic frameworkIntroduction to Ionic framework
Introduction to Ionic framework
Shyjal Raazi
 
Try Jetpack Compose
Try Jetpack ComposeTry Jetpack Compose
Try Jetpack Compose
LutasLin
 
React Native
React NativeReact Native
React Native
Fatih Şimşek
 
OpenTelemetryでWebシステムの処理を追跡しよう - DjangoCongress JP 2022
OpenTelemetryでWebシステムの処理を追跡しよう - DjangoCongress JP 2022OpenTelemetryでWebシステムの処理を追跡しよう - DjangoCongress JP 2022
OpenTelemetryでWebシステムの処理を追跡しよう - DjangoCongress JP 2022
Takayuki Shimizukawa
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kata
Paul Blundell
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptx
GDSCVJTI
 
MQTTとAMQPと.NET
MQTTとAMQPと.NETMQTTとAMQPと.NET
MQTTとAMQPと.NET
terurou
 
iOS Architecture
iOS ArchitectureiOS Architecture
iOS Architecture
Jacky Lian
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
Andreas Jakl
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
Sashko Stubailo
 
Mastering Chaos - A Netflix Guide to Microservices
Mastering Chaos - A Netflix Guide to MicroservicesMastering Chaos - A Netflix Guide to Microservices
Mastering Chaos - A Netflix Guide to Microservices
C4Media
 
CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~
CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~
CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~
SEGADevTech
 
Microsoft Azure Logic apps
Microsoft Azure Logic appsMicrosoft Azure Logic apps
Microsoft Azure Logic apps
CloudFronts Technologies LLP.
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
amaankhan
 
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
NGINX, Inc.
 
平成26年度 滋賀県土地家屋調査士会研修会:「QGISを利用した幾何補正手法の習得」講師,大津地方法務局(滋賀県大津市),2014年11月10日.
平成26年度 滋賀県土地家屋調査士会研修会:「QGISを利用した幾何補正手法の習得」講師,大津地方法務局(滋賀県大津市),2014年11月10日.平成26年度 滋賀県土地家屋調査士会研修会:「QGISを利用した幾何補正手法の習得」講師,大津地方法務局(滋賀県大津市),2014年11月10日.
平成26年度 滋賀県土地家屋調査士会研修会:「QGISを利用した幾何補正手法の習得」講師,大津地方法務局(滋賀県大津市),2014年11月10日.
和人 青木
 
ホットペッパービューティーにおけるモバイルアプリ向けAPIのBFF/Backend分割
ホットペッパービューティーにおけるモバイルアプリ向けAPIのBFF/Backend分割ホットペッパービューティーにおけるモバイルアプリ向けAPIのBFF/Backend分割
ホットペッパービューティーにおけるモバイルアプリ向けAPIのBFF/Backend分割
Recruit Lifestyle Co., Ltd.
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
ModusJesus
 
Introduction to Ionic framework
Introduction to Ionic frameworkIntroduction to Ionic framework
Introduction to Ionic framework
Shyjal Raazi
 
Try Jetpack Compose
Try Jetpack ComposeTry Jetpack Compose
Try Jetpack Compose
LutasLin
 
OpenTelemetryでWebシステムの処理を追跡しよう - DjangoCongress JP 2022
OpenTelemetryでWebシステムの処理を追跡しよう - DjangoCongress JP 2022OpenTelemetryでWebシステムの処理を追跡しよう - DjangoCongress JP 2022
OpenTelemetryでWebシステムの処理を追跡しよう - DjangoCongress JP 2022
Takayuki Shimizukawa
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kata
Paul Blundell
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptx
GDSCVJTI
 
MQTTとAMQPと.NET
MQTTとAMQPと.NETMQTTとAMQPと.NET
MQTTとAMQPと.NET
terurou
 
iOS Architecture
iOS ArchitectureiOS Architecture
iOS Architecture
Jacky Lian
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
Andreas Jakl
 
GraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer toolsGraphQL: Enabling a new generation of API developer tools
GraphQL: Enabling a new generation of API developer tools
Sashko Stubailo
 
Mastering Chaos - A Netflix Guide to Microservices
Mastering Chaos - A Netflix Guide to MicroservicesMastering Chaos - A Netflix Guide to Microservices
Mastering Chaos - A Netflix Guide to Microservices
C4Media
 
CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~
CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~
CEDEC2021 Android iOS 実機上での自動テストをより楽に有意義にする為に ~端末管理・イメージ転送・動画記録等の周辺情報のノウハウ共有~
SEGADevTech
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
amaankhan
 

Similar to Combine in iOS - Basics (20)

Moving towards Reactive Programming
Moving towards Reactive ProgrammingMoving towards Reactive Programming
Moving towards Reactive Programming
Deepak Shevani
 
Rx Swift
Rx SwiftRx Swift
Rx Swift
Vincenzo Favara
 
RxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android MontréalRxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android Montréal
Sidereo
 
5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx
MohamedBilal73
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
CongTrung Vnit
 
Secret Twists to Efficiently Develop Reactive Software Systems
Secret Twists to Efficiently Develop Reactive Software SystemsSecret Twists to Efficiently Develop Reactive Software Systems
Secret Twists to Efficiently Develop Reactive Software Systems
Bart Jonkers
 
WoMakersCode 2016 - Shit Happens
WoMakersCode 2016 -  Shit HappensWoMakersCode 2016 -  Shit Happens
WoMakersCode 2016 - Shit Happens
Jackson F. de A. Mafra
 
How to Migrate Applications Off a Mainframe
How to Migrate Applications Off a MainframeHow to Migrate Applications Off a Mainframe
How to Migrate Applications Off a Mainframe
VMware Tanzu
 
JavaScript for ABAP Programmers - 7/7 Functional Programming
JavaScript for ABAP Programmers - 7/7 Functional ProgrammingJavaScript for ABAP Programmers - 7/7 Functional Programming
JavaScript for ABAP Programmers - 7/7 Functional Programming
Chris Whealy
 
Being Reactive with Spring
Being Reactive with SpringBeing Reactive with Spring
Being Reactive with Spring
Kris Galea
 
OpenWhisk Introduction
OpenWhisk IntroductionOpenWhisk Introduction
OpenWhisk Introduction
Ioana Baldini
 
Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...
Concetto Labs
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
Devin Bost
 
Spring, Functions, Serverless and You
Spring, Functions, Serverless and YouSpring, Functions, Serverless and You
Spring, Functions, Serverless and You
VMware Tanzu
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
Sistek Yazılım
 
Reactive programming intro
Reactive programming introReactive programming intro
Reactive programming intro
Ahmed Ehab AbdulAziz
 
The macro of microservices
The macro of microservicesThe macro of microservices
The macro of microservices
Software Guru
 
The Rest of the Best
The Rest of the BestThe Rest of the Best
The Rest of the Best
Kevlin Henney
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deployment
Filippo Zanella
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
VMware Tanzu
 
Moving towards Reactive Programming
Moving towards Reactive ProgrammingMoving towards Reactive Programming
Moving towards Reactive Programming
Deepak Shevani
 
RxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android MontréalRxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android Montréal
Sidereo
 
5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx
MohamedBilal73
 
Reactive programming with rx java
Reactive programming with rx javaReactive programming with rx java
Reactive programming with rx java
CongTrung Vnit
 
Secret Twists to Efficiently Develop Reactive Software Systems
Secret Twists to Efficiently Develop Reactive Software SystemsSecret Twists to Efficiently Develop Reactive Software Systems
Secret Twists to Efficiently Develop Reactive Software Systems
Bart Jonkers
 
How to Migrate Applications Off a Mainframe
How to Migrate Applications Off a MainframeHow to Migrate Applications Off a Mainframe
How to Migrate Applications Off a Mainframe
VMware Tanzu
 
JavaScript for ABAP Programmers - 7/7 Functional Programming
JavaScript for ABAP Programmers - 7/7 Functional ProgrammingJavaScript for ABAP Programmers - 7/7 Functional Programming
JavaScript for ABAP Programmers - 7/7 Functional Programming
Chris Whealy
 
Being Reactive with Spring
Being Reactive with SpringBeing Reactive with Spring
Being Reactive with Spring
Kris Galea
 
OpenWhisk Introduction
OpenWhisk IntroductionOpenWhisk Introduction
OpenWhisk Introduction
Ioana Baldini
 
Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...Guidelines to understand durable functions with .net core, c# and stateful se...
Guidelines to understand durable functions with .net core, c# and stateful se...
Concetto Labs
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
Devin Bost
 
Spring, Functions, Serverless and You
Spring, Functions, Serverless and YouSpring, Functions, Serverless and You
Spring, Functions, Serverless and You
VMware Tanzu
 
The macro of microservices
The macro of microservicesThe macro of microservices
The macro of microservices
Software Guru
 
The Rest of the Best
The Rest of the BestThe Rest of the Best
The Rest of the Best
Kevlin Henney
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deployment
Filippo Zanella
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
VMware Tanzu
 
Ad

Recently uploaded (20)

A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Reinventing Microservices Efficiency and Innovation with Single-RuntimeReinventing Microservices Efficiency and Innovation with Single-Runtime
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Natan Silnitsky
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
AI Agents with Gemini 2.0 - Beyond the Chatbot
AI Agents with Gemini 2.0 - Beyond the ChatbotAI Agents with Gemini 2.0 - Beyond the Chatbot
AI Agents with Gemini 2.0 - Beyond the Chatbot
Márton Kodok
 
Aligning Projects to Strategy During Economic Uncertainty
Aligning Projects to Strategy During Economic UncertaintyAligning Projects to Strategy During Economic Uncertainty
Aligning Projects to Strategy During Economic Uncertainty
OnePlan Solutions
 
Quasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoersQuasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoers
sadadkhah
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Call of Duty: Warzone for Windows With Crack Free Download 2025
Call of Duty: Warzone for Windows With Crack Free Download 2025Call of Duty: Warzone for Windows With Crack Free Download 2025
Call of Duty: Warzone for Windows With Crack Free Download 2025
Iobit Uninstaller Pro Crack
 
Lumion Pro Crack + 2025 Activation Key Free Code
Lumion Pro Crack + 2025 Activation Key Free CodeLumion Pro Crack + 2025 Activation Key Free Code
Lumion Pro Crack + 2025 Activation Key Free Code
raheemk1122g
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
How to Create a Crypto Wallet Like Trust.pptx
How to Create a Crypto Wallet Like Trust.pptxHow to Create a Crypto Wallet Like Trust.pptx
How to Create a Crypto Wallet Like Trust.pptx
riyageorge2024
 
Do not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your causeDo not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your cause
Fexle Services Pvt. Ltd.
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Reinventing Microservices Efficiency and Innovation with Single-RuntimeReinventing Microservices Efficiency and Innovation with Single-Runtime
Reinventing Microservices Efficiency and Innovation with Single-Runtime
Natan Silnitsky
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
AI Agents with Gemini 2.0 - Beyond the Chatbot
AI Agents with Gemini 2.0 - Beyond the ChatbotAI Agents with Gemini 2.0 - Beyond the Chatbot
AI Agents with Gemini 2.0 - Beyond the Chatbot
Márton Kodok
 
Aligning Projects to Strategy During Economic Uncertainty
Aligning Projects to Strategy During Economic UncertaintyAligning Projects to Strategy During Economic Uncertainty
Aligning Projects to Strategy During Economic Uncertainty
OnePlan Solutions
 
Quasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoersQuasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoers
sadadkhah
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Call of Duty: Warzone for Windows With Crack Free Download 2025
Call of Duty: Warzone for Windows With Crack Free Download 2025Call of Duty: Warzone for Windows With Crack Free Download 2025
Call of Duty: Warzone for Windows With Crack Free Download 2025
Iobit Uninstaller Pro Crack
 
Lumion Pro Crack + 2025 Activation Key Free Code
Lumion Pro Crack + 2025 Activation Key Free CodeLumion Pro Crack + 2025 Activation Key Free Code
Lumion Pro Crack + 2025 Activation Key Free Code
raheemk1122g
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
How to Create a Crypto Wallet Like Trust.pptx
How to Create a Crypto Wallet Like Trust.pptxHow to Create a Crypto Wallet Like Trust.pptx
How to Create a Crypto Wallet Like Trust.pptx
riyageorge2024
 
Do not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your causeDo not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your cause
Fexle Services Pvt. Ltd.
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Ad

Combine in iOS - Basics

  • 1. Introduction of Apple’s exciting new framework Combine
  • 2. Imperative vs Declarative Telling the machine how to do something and as a result what you want to happen will happen. Telling a machine what would like to happen and let the computer figure how to do it!
  • 4. Async in Swift Grand Central Dispatch NSOperationQueue POSIX Threads Target / Action Callbacks / Completion Handlers
  • 5. Some factors about async in swift Hard to understand More manual effort Callback hell Hard to maintain
  • 6. Reactive Programming, which focuses on asynchronous data streams, which you can listen to and react accordingly. Functional Programming, which emphasizes calculations via mathematical-style functions, immutability and expressiveness, and minimizes the use of variables and state. FRP is the combination of functional and reactive paradigms. In other words, it is reacting to data streams using the functional paradigm. Eg: RxSwift, ReactiveSwift Functional Reactive Programming
  • 7. What is Combine? Combine is a new reactive framework created by Apple that streamlines how you can process asynchronous operations. Combine code is declarative and succinct, making it easy to write and read once you have a basic understanding of it. Combine also allows you to neatly organize related code in one place instead of having that code spread out across multiple files.
  • 8. Publisher The essence of Combine is: publishers send values to subscribers. To become a publisher, a type must adopt and conform to the Publisher protocol, which includes the following: associatedtype Output associatedtype Failure : Error Specifically, a publisher must define the type of values it will send, and its failure error type or Never if it will never send an error.
  • 9. How to create publishers Combine is integrated throughout the iOS SDK and Swift standard library. For example, this enables us to create a publisher from a NotificationCenter.Notification, or even an array of primitive values.
  • 10. Subscriber A subscriber attaches to a publisher to receive values from it. And the process is called Subscription. Subscribers must adopt and conform to the Subscriber protocol, which includes the following: associatedtype Input associatedtype Failure: Error
  • 11. How to create subscription There are two ways to create a subscription to a publisher: ● By using one of the sink operators. ● By using one of the assign(to:on:) operators.
  • 12. Example Usecase 1 Chaining Asynchronous Calls
  • 13. Example Usecase 2 Performing Multiple Asynchronous Calls
  • 14. Example Usecase 3 Merges Two Notifications and maps them
  • 15. How to stop subscriptions There are two ways to stop subscriptions: ● Call cancel() on a subscription token. ● Do nothing and let normal memory management rules to apply, i.e., the token or collection of AnyCancellable will call cancel() on the subscriptions upon deinitialization.
  • 17. Major advantages Combine is integrated into many existing frameworks in iOS, macOS, watchOS, and tvOS. SwiftUI that relies heavily on Combine. The Foundation framework contains a lot of extensions to work with Combine. It allows to work with common types we are already familiar with: ● A URLSessionTask Publisher that publishes the data response or request error ● Operators for easy JSON decoding ● A Publisher for a specific Notification.Name that publishes the notification
  • 18. Combine Combine Deployment Target iOS 13.0+ Platforms supported iOS, macOS, tvOS, watchOS Spec Reactive Streams (+ adjustments) Framework Consumption First-party (built-in) Maintained by Apple UI Bindings SwiftUI

Editor's Notes

  • #7: Observer pattern Powerful operators Light and Switch
  • #8: 3 things in combine: Publisher, Subscriber and Operators
  • #10: We can create our own custom publisher types by adopting and conforming to the Publisher protocol. However there are two Publisher types that will most often suit your needs without having to define a custom publisher: PassthroughSubject and CurrentValueSubject.
  • #11: A subscriber can only have one subscription
  • #12: Sink The sink operators include closure parameters to handle values or a completion event received from a publisher. Assign assign method of Combine to bind a stream to a key path and therefore connect it to the properties of a view, but there is no way to get any stream from UI components.
  • #14: Usually, when we want to wait for two asynchronous operations to finish in order to perform a task, we have to use DispatchGroups and to do manual management. With Combine Swift, we can simply use zip operator explained form above.
  • #15: Merges Two Keyboard Notifications and maps them into current keyboard height. After that, it uses the height to assign to scroll view content insets.
  • #18: A URLSessionTask Publisher that publishes the data response or request error Operators for easy JSON decoding A Publisher for a specific Notification.Name that publishes the notification
  • #19: Have to wait for some time.