Essentials

Skipping

Reducing

Concatenating

  • startWith (soon)
  • endWith (soon)
  • concat (soon)

Combining

filter
versus
map take

Focus on map (soon)

Animated example
How it works

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 Contact Hire me

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

Receive my latest news, tips and animations:

Learn Reactive Programming and stay up-to-date:

News

@CedricSoulas