Combine and Functional reactive programming

Adaptivebyte.com / Blog  / MobileApps  / Combine and Functional reactive programming
a

Combine and Functional reactive programming

Combine has just like RxSwift observables and observers noted as publishers and subscribers and an extra concept feature known as back-pressure that gives the idea of cancelling the data flow when it wants(cancellable publishers).

Combine takes this further, enabling watching of properties, binding to objects, sending and receiving higher level events from UI controls, and supporting integration with almost all of Apple’s existing API ecosystem.

Main features: 
Creating pipelines ( sequence of asynchronous operations) – when a series of events are being executed and every result is passed to the next flow.
So we can create type checking(ui checks), series of actions on the interface as needed and not only the interface but other processing events.
Core concepts are: 
Publishers and subscribers
Operators
Subjects
Publishers and subscribers – are actually some protocols in swift
The publisher is the provider of data
Publishers have a common reactive behaviour like:
-return value immediately when requested by a subscriber ( sink, assign)
– they are Just and Future, Deferred, Empty, Sequence, Fail, Record, Share, MultiCast, ObservableObject, @Published
Operators are number of pre-built functions that are included under Publisher in Apple’s reference documentation. Operators are meant to be composed into pipelines.

Subjects are a special case of publisher that also adhere to the Subject protocol. This protocol requires subjects to have a .send(_:) method to allow the developer to send specific values to a subscriber (or pipeline).

LEAVE A COMMENT