filter

accepts 1 input stream, a predicate function

  • When the input stream emits a value, it is given to the predicate:
    • If the predicate returns ✔ true, the value is emitted
    • Otherwise, the value is ignored

returns a new stream of filtered values

map

accepts 1 input stream, a project function

  • When the input stream emits a value, it is given to the project function and the resulting value is emitted

returns a new stream of projected values

Published on Monday, 23 Oct. 2017
Revised on Monday, 8 Oct. 2018

Project vs Predicate

In the video example, ▬ isEven accepts a number as an argument:

  • If it is an even number, it returns ✔ true
  • Otherwise, it returns ✘ false

It is used as:

  • a project function on ❚ map
  • a predicate function on ❚ filter

A predicate returns ✔ true or ✘ false.

Learn more about project and predicate.

Cédric Soulas Follow Hire me

Freelance Developer Advocate. Motion graphics with code. JavaScript and Elm. cedricsoulas.com

Subscribe to reactive.how newsletter

Receive my latest news, tips and animations:

Learn Reactive Programming and stay up-to-date: