xxxxxxxxxx
A pure function is one that doesn’t have any side effects and has stable output – e.g. the same input will always produce the same output.
Working with pure functions makes code easier to reason, as there’s no hidden side effects and implicit dependencies between functions.
Given the composable nature of RxJava operators, a very good combination is keeping each operation a highly isolated pure function – this way alterations of the stream are easier.
xxxxxxxxxx
function addNumbers(num1,num2) {
return num1 + num2
}
Calling addNumbers(2,3) will ALWAYS equal 5.
A pure function is a function that always returns
the same result if the same arguments are passed
xxxxxxxxxx
const array = [1,2,3]
function addElementToArray(a,element){
return [a, element]
}
//invoce function
addElementToArray(array,4)
//[1,2,3,4]