SlideShare a Scribd company logo
1 of 16
Download to read offline
Immutability and Pure Functions
Or how to become a first-class citizen
About Me
Fullstack developer at SparkFabrik
@edodusi on twitter
Contact me!
Key concepts of functional programming
Higher-order / first class functions
Functions that take other functions as arguments or return functions as results
Pure functions
Referential transparency, idempotence, reversible order (thread safe)
Recursion
Function that invoke itself over and over until the base case is reached
Immutable state
Function execution is independent from the program state and doesn’t change it
Key concepts of functional programming
Partial Application
The process of applying a function to some of its arguments
Curry
Transform a functions with multiple parameters as input into a function
with exactly one parameter
MORE! MORE!
Pure functions
● No side-effects
● Stateless
● Idempotent
● Self-contained
● Thread-safe
● Composable
● Easy testability!
<?php
$memoize = function ($func) {
return function () use ($func) {
static $cache = [];
$args = func_get_args();
$key = md5(serialize($args));
if (!isset($cache[$key])) {
$cache[$key] = call_user_func_array($func, $args);
}
return $cache[$key];
};
};
$sum = $memoize('sum');
echo $sum(2, 3) . PHP_EOL;
Memoization is a caching
technique used to store the
results of function calls and
returning them if called with
the same input.
Immutability
<?php
$numbers = [1, 2, 3, 4, 5];
$sum = function ($x, $y) {
return $x + $y;
};
function sumArray($array) : callable {
return function ($sumFunction) use ($array): int {
return array_reduce($array, $sumFunction);
};
}
echo sumArray($numbers)($sum) . PHP_EOL;
The program’s state doesn’t
change during the execution.
It’s immutable.
If we compose pure functions
we are sure that this is true on
every execution, on every
machine, on every scale.
let add = (a, b) => a + b;
let increment = add.bind(null, 1);
increment(2);
// 3
let add = x => y => x + y;
let increment = add(1);
increment(2);
// 3
add(1)(2);
Partial application
Currying
<?php
$numbers = [1, 2, 3, 4, 5];
$sum = function ($x, $y) {
return $x + $y;
};
function sumArray($array) : callable {
return function ($sumFunction) use ($array): int {
return array_reduce($array, $sumFunction);
};
}
echo sumArray($numbers)($sum) . PHP_EOL;
Currying is transforming a
function that takes multiple
arguments into a chain of
functions each with a single
argument
This leads to function
composition.
this.http
.get(uri, { params })
.then(data => doThis(data))
.then(data => doThat(data))
.then(() => log())
.catch(e => handleError(e))
Promises
this.http
.get<Response>(uri, { params })
.pipe(
filter(data => isPositive(data)),
map(data => doSomething(data)),
catchError(error => {
console.error(error);
handleError(error)});
})
)
Promises (pipe)
parallel([
readFile(‘./file’),
http.get(‘url’),
db.get(‘user.name’)
], () => {
console.log(file);
console.log(user);
});
List of tasks
tasks = [
readFile(‘./file’),
http.get(‘url’),
db.get(‘user.name’)
];
file = tasks[0].then();
Promises.all(tasks).then();
With promises
export interface State {
page: Page;
loaded: boolean;
loading: boolean;
validated: boolean;
components: Array<any>;
}
function reducer(state = initialState): State {
return {
...state,
loaded: false,
loading: true
};
}
Redux state
Animation credits Hristo Georgiev: https://www.pluralsight.com/guides/building-a-redux-application-with-angular-2-part-1

More Related Content

What's hot

Lecture 7 Templates, Friend Classes
Lecture 7 Templates, Friend ClassesLecture 7 Templates, Friend Classes
Lecture 7 Templates, Friend Classes
bunnykhan
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
Deepak Singh
 
Cold fusion best practice
Cold fusion best practiceCold fusion best practice
Cold fusion best practice
isummation
 
Jfokus functional groovy
Jfokus functional groovyJfokus functional groovy
Jfokus functional groovy
Andres Almiray
 
Web app development_php_05
Web app development_php_05Web app development_php_05
Web app development_php_05
Hassen Poreya
 

What's hot (20)

Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Lecture 7 Templates, Friend Classes
Lecture 7 Templates, Friend ClassesLecture 7 Templates, Friend Classes
Lecture 7 Templates, Friend Classes
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
Inline function
Inline functionInline function
Inline function
 
Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & Promises
 
Php, mysq lpart3
Php, mysq lpart3Php, mysq lpart3
Php, mysq lpart3
 
Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in java
 
Programming Global variable
Programming Global variableProgramming Global variable
Programming Global variable
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
 
Closures
ClosuresClosures
Closures
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generators
 
Cold fusion best practice
Cold fusion best practiceCold fusion best practice
Cold fusion best practice
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Inline and lambda function
Inline and lambda functionInline and lambda function
Inline and lambda function
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
Jfokus functional groovy
Jfokus functional groovyJfokus functional groovy
Jfokus functional groovy
 
Rspec
RspecRspec
Rspec
 
Web app development_php_05
Web app development_php_05Web app development_php_05
Web app development_php_05
 

Similar to Immutability and pure functions

Similar to Immutability and pure functions (20)

Functional programming
Functional programmingFunctional programming
Functional programming
 
Function
Function Function
Function
 
Functional programming 101
Functional programming 101Functional programming 101
Functional programming 101
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
 
The Functional Programming Toolkit (NDC Oslo 2019)
The Functional Programming Toolkit (NDC Oslo 2019)The Functional Programming Toolkit (NDC Oslo 2019)
The Functional Programming Toolkit (NDC Oslo 2019)
 
Functions
FunctionsFunctions
Functions
 
C function presentation
C function presentationC function presentation
C function presentation
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
 
C function
C functionC function
C function
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptx
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
 
Basic information of function in cpu
Basic information of function in cpuBasic information of function in cpu
Basic information of function in cpu
 
Function in c program
Function in c programFunction in c program
Function in c program
 
php user defined functions
php user defined functionsphp user defined functions
php user defined functions
 
Functional Paradigm.pptx
Functional Paradigm.pptxFunctional Paradigm.pptx
Functional Paradigm.pptx
 

More from sparkfabrik

More from sparkfabrik (20)

KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on KubernetesKCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
 
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
 
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirtIAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
 
2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte
 
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
 
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP EcosystemWhat is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
 
UX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdfUX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdf
 
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
 
Deep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloudDeep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloud
 
KCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with CrossplaneKCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with Crossplane
 
Come Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagineCome Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagine
 
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native modernoDrupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
 
Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!
 
Progettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWSProgettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWS
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
 
Headless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIsHeadless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIs
 
Cloud-Native Drupal: a survival guide
Cloud-Native Drupal: a survival guideCloud-Native Drupal: a survival guide
Cloud-Native Drupal: a survival guide
 
Mobile Development: una introduzione per Web Developers
Mobile Development: una introduzione per Web DevelopersMobile Development: una introduzione per Web Developers
Mobile Development: una introduzione per Web Developers
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
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-...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
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...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
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
 

Immutability and pure functions

  • 1. Immutability and Pure Functions Or how to become a first-class citizen
  • 2. About Me Fullstack developer at SparkFabrik @edodusi on twitter Contact me!
  • 3. Key concepts of functional programming Higher-order / first class functions Functions that take other functions as arguments or return functions as results Pure functions Referential transparency, idempotence, reversible order (thread safe) Recursion Function that invoke itself over and over until the base case is reached Immutable state Function execution is independent from the program state and doesn’t change it
  • 4. Key concepts of functional programming Partial Application The process of applying a function to some of its arguments Curry Transform a functions with multiple parameters as input into a function with exactly one parameter MORE! MORE!
  • 5. Pure functions ● No side-effects ● Stateless ● Idempotent ● Self-contained ● Thread-safe ● Composable ● Easy testability!
  • 6. <?php $memoize = function ($func) { return function () use ($func) { static $cache = []; $args = func_get_args(); $key = md5(serialize($args)); if (!isset($cache[$key])) { $cache[$key] = call_user_func_array($func, $args); } return $cache[$key]; }; }; $sum = $memoize('sum'); echo $sum(2, 3) . PHP_EOL; Memoization is a caching technique used to store the results of function calls and returning them if called with the same input.
  • 8. <?php $numbers = [1, 2, 3, 4, 5]; $sum = function ($x, $y) { return $x + $y; }; function sumArray($array) : callable { return function ($sumFunction) use ($array): int { return array_reduce($array, $sumFunction); }; } echo sumArray($numbers)($sum) . PHP_EOL; The program’s state doesn’t change during the execution. It’s immutable. If we compose pure functions we are sure that this is true on every execution, on every machine, on every scale.
  • 9. let add = (a, b) => a + b; let increment = add.bind(null, 1); increment(2); // 3 let add = x => y => x + y; let increment = add(1); increment(2); // 3 add(1)(2); Partial application Currying
  • 10. <?php $numbers = [1, 2, 3, 4, 5]; $sum = function ($x, $y) { return $x + $y; }; function sumArray($array) : callable { return function ($sumFunction) use ($array): int { return array_reduce($array, $sumFunction); }; } echo sumArray($numbers)($sum) . PHP_EOL; Currying is transforming a function that takes multiple arguments into a chain of functions each with a single argument This leads to function composition.
  • 11. this.http .get(uri, { params }) .then(data => doThis(data)) .then(data => doThat(data)) .then(() => log()) .catch(e => handleError(e)) Promises
  • 12. this.http .get<Response>(uri, { params }) .pipe( filter(data => isPositive(data)), map(data => doSomething(data)), catchError(error => { console.error(error); handleError(error)}); }) ) Promises (pipe)
  • 13. parallel([ readFile(‘./file’), http.get(‘url’), db.get(‘user.name’) ], () => { console.log(file); console.log(user); }); List of tasks
  • 14. tasks = [ readFile(‘./file’), http.get(‘url’), db.get(‘user.name’) ]; file = tasks[0].then(); Promises.all(tasks).then(); With promises
  • 15. export interface State { page: Page; loaded: boolean; loading: boolean; validated: boolean; components: Array<any>; } function reducer(state = initialState): State { return { ...state, loaded: false, loading: true }; } Redux state
  • 16. Animation credits Hristo Georgiev: https://www.pluralsight.com/guides/building-a-redux-application-with-angular-2-part-1