Reactive Programming
Reactive Programming?
• Reactive Programming is design pattern that focuses on use of asynchronous and non-
blocking data streams to handle data and events.
• Help us to increase Efficiency and Scalability of applications.
Synchronous and Blocking
30 min(wait)
Thread1
Thread2
Client
Thread3
Asynchronous and Non-Blocking
30 min(wait)
Thread1
Request1 After 30 min
Request2
Client
Response
Features of Reactive Programming
• Asynchronous and non-blocking
• Functional Style coding
• Data flow as event driven
• Backpressure of DataStream
Reactive Stream Specification
Reactive programming has some rules these rules is known as Specification
There are 4 main interfaces
• Publisher
• Subscriber
• Subscription
• Processor
Publisher
Act as data source.
Subscriber
Act as data receiver.
Subscription
Request data from Publisher or cancel a request.
Processor
Processor interface is the combination of both Publisher and Subscriber interfaces.
Pub Sub Event Flow
onComplete()
……n…
onNext(data)
onNext(data)
Publisher
Subscriber
request(n)
onSubscribe(Subs
cription s)
subscribe(Subscrib
er r)