Introduction: Manipulating Streams

Let’s see how Rx revolves around manipulating data in streams and its interesting use cases.

Before starting this lesson, let’s answer some questions:

  • Why do I want to read this?

    You’ve now learned the basics of creating streams, so the other half of learning Observables is how to manipulate those streams.

  • What will I learn?

    You’ll learn a bunch of common operators used to change/manipulate streams in progress.

  • What will I be able to do that I couldn’t do before?

    Instead of just detecting when events happen, we can change the events as they happen.

  • Where are we going next, and how does this fit in?

    Next, we’ll start applying these concepts to async operations.

Manipulating streams

In the last chapter, you learned how to create observables with new Observable, along with a few of the helper operators Rx provides.

You also peeked into the world of manipulating values in an observable stream with the magic of map. While mapping is a common pattern, the Rx library has many other operators for working with in-stream data.

In fact, most Rx work is about manipulating the data as it comes down the stream. This change can be in the form of manipulating the data directly (map), changing the timing of the data (delay), or operating on the observables themselves (takeUntil).

This chapter expands your knowledge of the types of map functions available and adds several new types of operators to your tool belt:

  • mergeMap combines flattening and mapping into a single operation.
  • filter allows a stream to be picky about what values are allowed.
  • The tap operator is a unique case that doesn’t manipulate the stream’s values directly but allows a developer to tap into the stream and debug it.

Pig Latin translator project

The first of two projects in this chapter is a Pig Latin translator. Through this translator, you’ll learn how to manipulate values as they pass through an observable stream.

Typeahead tool project

The second project, a typeahead tool takes the concepts from the Pig Latin translator and builds a more complicated tool out of them, teaching you how to debug in-flight data.

Get hands-on with 1200+ tech skills courses.