SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
Рак мозга или мозг рака
Раком можно все
1023
A for Architecture
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Persistence
Notifications
Runtime
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
NSNotification
LocationUpdate
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Networking
Networking policies
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
HTTP.Request
HTTP.Response
HTTP.Error
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
API Request
Persistence Request
Application Service wrapper
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Update request
Value Object
Service Object
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Business logic
Logic state
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Model Object
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Application State
Presentation Logic
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Bindings
Presentables
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Presentation
UI State
•Application Layer
•Transport Layer
•Service Layer
•Model Layer
•ViewModel Layer
•View Layer
Presenters
UIObjects
Foundation Types
Data Flow
1024
Data + Data Request Flow
Transport Layer
Transport Layer
Transport Layer + Errors
Transport Layer + Binding
And now?
RAC
• Signal
• SignalProducer
• Action
• Property
• Result
RAC
• Signal
• SignalProducer
• Action
• Property
• Result
• Pipeline
• Future Task
• Future Builder
• Reactive State
• Enum<Value | Error>
RAC
• Signal
• SignalProducer
• Action
• Property
• Result
• NSNotificationCenter
• startWithCompletion:
• startWithInput:Completions
• value + KVO
• completions(result, error)
RAC + Transforms
• Signal -> Signal - Operator
• Signal.map(transform)
• Signal.retry(3)
• Signal -> Signal -> Signal - pipeline
- retry(map(signal, transform), 3)
✓ signal.map(transform).retry(3)
RAC + (flat)map
Transport Layer + RAC
Transport Layer + RAC
let requestAction = Action<URLRequest, URLResponse, Error> { .../*future task*/ }
let http = Action<Request, Response, Error> { request in
return Result<Request, Error>(value: request)
.flatMap(serialize) //Result<JSON, Error>
.flatMap(requestBuilder(forConfiguration: configuration)) //Result<URLRequest, Error>
.map(SignalProducer.init) //SignalProducer<URLRequest, Error>
.flatMap(.Latest, transform: requestAction.apply) //SignalProducer<URLResponse, Error>
.attemptMap(deserialize) //SignalProducer<Response Error
}
Заметьте - эта штука вполне может
быть общей вне зависимости от
входных и выходных данных засчет
generic
Build Your Own RAC
extension SignalType {
/// Returns a signal that will yield an array of values when `self` completes.
@warn_unused_result(message="Did you forget to call `observe` on the signal?")
public func collect() -> Signal<[Value], Error> {
return self
.reduce(CollectState()) { $0.append($1) }
.map { $0.values }
}
}
Transport Layer + RAC
let httpWithPolicy = Action<Request, Response, Error> { request in
http.apply(request)
.retry(3)
.suspendOn(enterBackgroundSignal: background, enterForeground: foreground)
}
Service Layer
Service Layer
Service Layer + RAC
let service = Action<Number, Image, Error> { number in
let image = cacheService.inquire
.apply(number)
.concat { xkcdImageHTTP.apply(number) }
let description = xkcdDescriptionHTTP.apply(number)
return combineLatest(image, description).map { ImageWithDescription(image: $0, description: $1) }
}
Model Layer
Model Layer
Model Layer + RAC
struct State {
let number: Int
let value: AnyProperty<ImageWithDescription?>
init(number: Int) {
self.number = number
self.value = AnyProperty(value: nil, producer: service.apply(number))
}
}
let state = MutableProperty(State(number: 100))
let increment = { number.value = State(number: number.value.number + 1) }
let exposedState = AnyProperty(state)
View Model Layer
View Model Layer
VM Layer + RAC
let image = model.exposedState
.flatMap { $0.value.image }
.map { $0 ?? imagePlaceholder }
let description = model.exposedState
.flatMap { $0.value.description }
.map { $0 ?? "Loading..." }
let rightButtonAction = model.increment
let present = { presenters in
presenters.rightButtonAction <~ rightButtonAction
presenters.description <~ description.producer
presenters.image <~ description.image
}
View Layer
View + RAC
class View {
//{ self.imageView.image = $0 }
let image: Presenter<UIImage> = self.imageView.imagePresenter
//{ self.descriptionLabel.value = $0 }
let description: Presenter<String> = self.descriptionLabel.textPresenter
//{ self.button.clickedSignal.observe($0) }
let rightButton: Presenter<() -> ()> = self.button.clickActionPresenter
}
Hm…
Benefits?
• Consistency
• Observability
• Testability
• Encapsulation
• Completeness
Examples?
Popup Action
Navigation Property + Actions
UIKit Sinks + Presentables
Login Form Action + Operators
What’s next?
• RXMarbles (http://rxmarbles.com/)
• Reactive Cocoa sources - all here
Questions?

Mais conteúdo relacionado

Mais procurados

20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final
David Lapsley
 

Mais procurados (20)

No internet? No Problem!
No internet? No Problem!No internet? No Problem!
No internet? No Problem!
 
jQuery - Chapter 5 - Ajax
jQuery - Chapter 5 -  AjaxjQuery - Chapter 5 -  Ajax
jQuery - Chapter 5 - Ajax
 
Client-side Rendering with AngularJS
Client-side Rendering with AngularJSClient-side Rendering with AngularJS
Client-side Rendering with AngularJS
 
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
 
Cycle.js - A functional reactive UI framework
Cycle.js - A functional reactive UI frameworkCycle.js - A functional reactive UI framework
Cycle.js - A functional reactive UI framework
 
Reporting solutions for ADF Applications
Reporting solutions for ADF ApplicationsReporting solutions for ADF Applications
Reporting solutions for ADF Applications
 
20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax here
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsBOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala apps
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
Streams or Loops? Java 8 Stream API by Niki Petkov - Proxiad Bulgaria
Streams or Loops? Java 8 Stream API by Niki Petkov - Proxiad BulgariaStreams or Loops? Java 8 Stream API by Niki Petkov - Proxiad Bulgaria
Streams or Loops? Java 8 Stream API by Niki Petkov - Proxiad Bulgaria
 
[QE 2018] Łukasz Gawron – Testing Batch and Streaming Spark Applications
[QE 2018] Łukasz Gawron – Testing Batch and Streaming Spark Applications[QE 2018] Łukasz Gawron – Testing Batch and Streaming Spark Applications
[QE 2018] Łukasz Gawron – Testing Batch and Streaming Spark Applications
 
From android/ java to swift (2)
From android/ java to swift (2)From android/ java to swift (2)
From android/ java to swift (2)
 
Vaadin+Scala
Vaadin+ScalaVaadin+Scala
Vaadin+Scala
 
Scalaz
ScalazScalaz
Scalaz
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
Reactive data visualisations with Om
Reactive data visualisations with OmReactive data visualisations with Om
Reactive data visualisations with Om
 
RichFaces: more concepts and features
RichFaces: more concepts and featuresRichFaces: more concepts and features
RichFaces: more concepts and features
 
Workshop 25: React Native - Components
Workshop 25: React Native - ComponentsWorkshop 25: React Native - Components
Workshop 25: React Native - Components
 

Semelhante a iOS Reactive Cocoa Pipeline

Semelhante a iOS Reactive Cocoa Pipeline (20)

Rack
RackRack
Rack
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019
 
Ntg web services
Ntg   web servicesNtg   web services
Ntg web services
 
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
Using Apache Calcite for Enabling SQL and JDBC Access to Apache Geode and Oth...
 
(DEV309) From Asgard to Zuul: How Netflix’s Proven Open Source Tools Can Help...
(DEV309) From Asgard to Zuul: How Netflix’s Proven Open Source Tools Can Help...(DEV309) From Asgard to Zuul: How Netflix’s Proven Open Source Tools Can Help...
(DEV309) From Asgard to Zuul: How Netflix’s Proven Open Source Tools Can Help...
 
Universal JavaScript
Universal JavaScriptUniversal JavaScript
Universal JavaScript
 
SharePoint REST vs CSOM
SharePoint REST vs CSOMSharePoint REST vs CSOM
SharePoint REST vs CSOM
 
Dev309 from asgard to zuul - netflix oss-final
Dev309  from asgard to zuul - netflix oss-finalDev309  from asgard to zuul - netflix oss-final
Dev309 from asgard to zuul - netflix oss-final
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
An Application Centric Approach to Devops
An Application Centric Approach to DevopsAn Application Centric Approach to Devops
An Application Centric Approach to Devops
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
les07.pdf
les07.pdfles07.pdf
les07.pdf
 
Data Pipeline at Tapad
Data Pipeline at TapadData Pipeline at Tapad
Data Pipeline at Tapad
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-action
 
Unleashing your Kafka Streams Application Metrics!
Unleashing your Kafka Streams Application Metrics!Unleashing your Kafka Streams Application Metrics!
Unleashing your Kafka Streams Application Metrics!
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's Next
 
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...
 
A real-world Relay application in production - Stefano Masini - Codemotion Am...
A real-world Relay application in production - Stefano Masini - Codemotion Am...A real-world Relay application in production - Stefano Masini - Codemotion Am...
A real-world Relay application in production - Stefano Masini - Codemotion Am...
 
Introduction to CloudStack API
Introduction to CloudStack APIIntroduction to CloudStack API
Introduction to CloudStack API
 

Último

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 

Último (20)

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

iOS Reactive Cocoa Pipeline