Streams
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
Definition
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
- But first, an experiment!
- Flowing through instead of stopping every step
- List structure, but not all values at once (Delayed List)
- Operate without having to know or care when the data flow ends (or if it ever ends)
- Operate without having to know or care how much data is in the stream in total
A
B
C
A
B
C
Have you used streams?
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
youtube.com
Have you used streams?
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
Pipes
When? / Why?
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
- Can't / Don't want to hold everything in memory
- Use less bandwidth
- Able to work with (potentially) infinite data
- Separation of concerns (e.g. in Unix)
Push Streams
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
- Producer: "Have the data."
- Pushes data out
- Someone handles it when it arrives
- "Callback"
- Non-blocking
- Possible overload: "back pressure"
- Block at the source
- Sample (most recent)
- First only
- Debounce
- Buffer
- ...
Pull Streams
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
- Consumer: "Can I get some data?"
- Consumer gets data themselves
- "Iterator"
- Blocking: "Timeout"
Reactive
Reactive?
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
Passive Reactive
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
Foo updates Bar when something in Foo changes
Bar listenes to Events happening in Foo and updates itself
Reacts to an Event
$('#cats-btn').click(function () {
getDataFromServer('cats');
});
function formatCats(cat) {
return { name: 'Hello ' + cat.name }
}
function renderUI(data) {
UI.render(data);
}
function getDataFromServer(type) {
$.ajax(URL + type).done(function (cats) {
renderUI(cats.map(formatCats));
});
}
_('click', $('#cats-btn'))
.pipe(getDataFromServer)
.map(formatCats)
.pipe(UI.render);
- No intermediate variables
- Clear data flow
- Doesn't work with individual events, but instead with event streams
- Raises the abstraction level - focus on implementation of events rather than combined details
Passive Reactive
In computing, reactive programming is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate change through the data flow.
Reactive Pattern
By queicherius
Reactive Pattern
- 891