In Reactive Programming, operators take one or several input streams and return a new stream. Some operators may accept additional arguments, such as functions:
These functions donāt have to work with the input or the output stream: they usually just transform, compare or combine values. The operators do work with the streams, in conjunction with these functions.
How you label a function (eg. āprojectā or āpredicateā function) depends on how you use it.
A function that:
valuesnew value of any typemay be used as a project function on combining operators (eg. combineLatest or zip).
A function that:
valuenew value of any typemay be used as a project function with map.
A function that:
valuenew value of type boolean (ā true or ā false)may be used as a predicate function on filtering operators (eg. filter, takeWhile or skipWhile)
As you may have noticed, a function used as a predicate can also be used as project function on a map operator:
In this example, the function n ā¶ n == 1, that returns ā true or ā false, is used both as an argument for map as a project and for filter as a predicate. As a result:
boolean values, according to the result of this project functionā true
FreelanceĀ DeveloperĀ Advocate. Motion graphics with code. JavaScriptĀ andĀ Elm. cedricsoulas.com
Receive my latest news, product updates and programming visualizations. You can unsubscribe at any time.