Egghead Instructor André Staltz

André Staltz

Andre is a user interface engineer at Futurice, with extensive knowledge
in reactive programming. He is a contributor to RxJS, has built
RxMarbles, written an introduction to reactive programming which went
viral, and collaborated to design ReactiveX.io. His current mission is
to redefine how we understand and structure user interfaces with the
reactive web framework Cycle.js.



Unlock all of André's PRO Lessons
click for instant access!

Browse André Staltz's lessons.

showing 107 lessons...

Make Observables hot only where necessary

P

Know when to extend the Observable class

P

Implement pause and resume feature correctly through RxJS

P

Convert an underlying source of data into an Observable

P

Move important side effects from do() to subscribe()

P

Replace zip with combineLatest when combining sources of data

P

Use switchMap to avoid leaks when flattening

P

Use takeUntil instead of manually unsubscribing from Observables

P

Use flattening operators instead of nested subscriptions

P

Use the map operator instead of firing events on a Subject

P

Convert RxJS Subjects to Observables

P

Replace Observable.create with Observable creation helpers

P

Split an RxJS observable conditionally with windowToggle

P

Split an RxJS observable with window

P

Use groupBy in real RxJS applications

P

Use switchMap as a safe default to flatten observables in RxJS

P

Use RxJS mergeMap for fine-grain custom behavior

P

Split an RxJS Observable into groups with groupBy

P

Use RxJS concatMap to map and concat high order observables

P

Use RxJS mergeMap to map and merge high order observables

P

Flatten a higher order observable with concatAll in RxJS

P

Use RxJS switchMap to map and flatten higher order observables

P

Flatten a higher order observable with mergeAll in RxJS

P

Get started with higher order observables in RxJS

Flatten a higher order observable with RxJS switch

P

Conclusion: when to use Subjects

ReplaySubject: remembering events from the past

Multicast with a selector argument, as a sandbox

Reusable multicasting with Subject factories

Multicasting shortcuts: publish() and variants

Stopping a shared observable execution

RefCount: automatically starting and stopping an execution

Connection operator: multicast and connect

Using a Subject as an Event Bus

BehaviorSubject: representing a value over time

AsyncSubject: representing a computation that yields a final value

Subject: an Observable and Observer hybrid

An Observable execution may only have one Observer

More operators and conclusion

P

Error handling operator: retry and retryWhen

P

Transformation operator: repeat

P

Error handling operator: catch

P

Filtering operators: distinct and distinctUntilChanged

P

Filtering operators: throttle and throttleTime

P

Transformation operators: debounce and debounceTime

P

Transformation operators: delay and delayWhen

P

Transformation operator: buffer

P

Transformation operator: scan

P

Combination operator: zip

P

Combination operator: withLatestFrom

P
rx tutorial about Make Observables hot only where necessary

Make Observables hot only where necessary

7:34 rx PRO

Operators like publish(), refCount(), share() make it easy to convert a cold Observable to a hot one, and are often necessary to get some feature done. In this lesson we will learn when exactly do we need to convert to hot, and when can we leave the Observable cold.

rx tutorial about Know when to extend the Observable class

Know when to extend the Observable class

7:25 rx PRO

The Observable in RxJS is a JavaScript class, and can be extended. In this lesson we will learn about those cases where extending the Observable class becomes a problem, and what cases where it makes sense to extend it.

rx tutorial about Implement pause and resume feature correctly through RxJS

Implement pause and resume feature correctly through RxJS

5:48 rx PRO

Eventually you will feel the need for pausing the observation of an Observable and resuming it later. In this lesson we will learn about use cases where pausing is possible, and what to do when pausing is impossible.

rx tutorial about Convert an underlying source of data into an Observable

Convert an underlying source of data into an Observable

3:54 rx PRO

While there are many cases where we often believe that an RxJS Subject is necessary, there is a way of avoiding them. In this lesson we will see how to identify the underlying source of data and convert it into an Observable, essentially eliminating the use of an error-prone Subject.

rx tutorial about Move important side effects from do() to subscribe()

Move important side effects from do() to subscribe()

4:30 rx PRO

The do() operator allows us to perform side effects in the chain of operators. However, there are limited use cases for do(). We will learn what those use cases are and how to use subscribe() most of the times.

rx tutorial about Replace zip with combineLatest when combining sources of data

Replace zip with combineLatest when combining sources of data

3:01 rx PRO

This lesson will highlight the true purpose of the zip operator, and how uncommon its use cases are. In its place, we will learn how to use the combineLatest operator.

rx tutorial about Use switchMap to avoid leaks when flattening

Use switchMap to avoid leaks when flattening

3:04 rx PRO

While flatMap is popular and convenient for flattening higher-order Observables, it can introduce new kinds of bugs related to subscriptions. In this lesson we will see how switchMap is a sensible default that avoids common bugs.

rx tutorial about Use takeUntil instead of manually unsubscribing from Observables

Use takeUntil instead of manually unsubscribing from Observables

3:52 rx PRO

Manually unsubscribing from subscriptions is safe, but tedious and error-prone. This lesson will teach us about the takeUntil operator and its utility to make unsubscribing automatic.

rx tutorial about Use flattening operators instead of nested subscriptions

Use flattening operators instead of nested subscriptions

4:00 rx PRO

We are going to see how to avoid virtually any case of a subscribe happening inside another subscribe by replacing it with a flattening operator such as flatMap or mergeAll.

rx tutorial about Use the map operator instead of firing events on a Subject

Use the map operator instead of firing events on a Subject

2:10 rx PRO

In this lesson we will learn how to replace excessive subscribing and Subject emissions with simple uses of the map operator, simplifying our code and making it less bug-prone.

rx tutorial about Convert RxJS Subjects to Observables

Convert RxJS Subjects to Observables

4:07 rx PRO

The use of RxJS Subjects is common, but not without problems. In this lesson we will see how they can be usually safely replaced with plain Observables.

rx tutorial about Replace Observable.create with Observable creation helpers

Replace Observable.create with Observable creation helpers

2:06 rx PRO

In this lesson we will learn about potential problems that may arise when using Observable.create, a low-level function for creating Observables. In its place, we will use easier helper functions that create Observables in a safe manner.

rx tutorial about Split an RxJS observable conditionally with windowToggle

Split an RxJS observable conditionally with windowToggle

4:32 rx PRO

There are variants of the window operator that allow you to split RxJS observables in different ways. In this lesson we will explore the windowToggle variant and see one of its use cases in user interfaces.

rx tutorial about Split an RxJS observable with window

Split an RxJS observable with window

6:58 rx PRO

Mapping the values of an observable to many inner observables is not the only way to create a higher order observable. RxJS also has operators that take a first order observable and return a higher order Observable. In this lesson we will learn about window, an operator to split an observable.

rx tutorial about Use groupBy in real RxJS applications

Use groupBy in real RxJS applications

5:21 rx PRO

This lesson will show when to apply groupBy in the real world. This RxJS operator is best suited when a source observable represents many data sources, e.g. an observable for multitouch events.

rx tutorial about Use switchMap as a safe default to flatten observables in RxJS

Use switchMap as a safe default to flatten observables in RxJS

3:39 rx PRO

In this lesson we look at the common strategies for creating and flattening higher order observables in RxJS. In particular, we give switchMap a careful review. It is an operator that works as an "asyncMap" and is capable of solving many of our asynchronous problems in JavaScript.

rx tutorial about Use RxJS mergeMap for fine-grain custom behavior

Use RxJS mergeMap for fine-grain custom behavior

5:39 rx PRO

RxJS operators mergeMap and switchMap are useful for handling asynchronous responses from the server, but they can do much more. In this lesson, we will see how to use mergeMap to achieve the same functionality as map() or filter() or other custom behaviors.

rx tutorial about Split an RxJS Observable into groups with groupBy

Split an RxJS Observable into groups with groupBy

4:02 rx PRO

groupBy() is another RxJS operator to create higher order observables. In this lesson we will learn how groupBy works for routing source values into different groups according to a calculated key.

rx tutorial about Use RxJS concatMap to map and concat high order observables

Use RxJS concatMap to map and concat high order observables

2:11 rx PRO

Like switchMap and mergeMap, concatMap is a shortcut for map() followed by a concatAll(). In this lesson we will explore this RxJS operator and its properties.

rx tutorial about Use RxJS mergeMap to map and merge high order observables

Use RxJS mergeMap to map and merge high order observables

4:00 rx PRO

Like RxJS switchMap() is a shortcut for map() and switch(), we will see in this lesson how mergeMap() is a shortcut for map() and mergeAll(), and learn its arguments for customised behavior.

rx tutorial about Flatten a higher order observable with concatAll in RxJS

Flatten a higher order observable with concatAll in RxJS

3:22 rx PRO

Besides switch and mergeAll, RxJS also provides concatAll as a flattening operator. In this lesson we will see how concatAll handles concurrent inner Observables and how it is just mergeAll(1).

rx tutorial about Use RxJS switchMap to map and flatten higher order observables

Use RxJS switchMap to map and flatten higher order observables

6:04 rx PRO

In this lesson, we will learn about switchMap, a shortcut for mapping to a higher order RxJS Observable, then flattening with switch. We will also see a practical example with network requests that would be used in the real world.

rx tutorial about Flatten a higher order observable with mergeAll in RxJS

Flatten a higher order observable with mergeAll in RxJS

3:19 rx PRO

Among RxJS flattening operators, switch is the most commonly used operator. However, it is important to get acquainted with mergeAll, another flattening operator which allows multiple concurrent inner observables. In this lesson we will explore mergeAll in detail.

rx tutorial about Get started with higher order observables in RxJS

Get started with higher order observables in RxJS

4:35 rx

An Observable may emit values of any JavaScript type: numbers, strings, booleans, objects, etc. This means an RxJS Observable may also happen to emit values which are themselves observables too. In this lesson we will learn more about this use case and begin learning about the so-called "higher order observables".

rx tutorial about Flatten a higher order observable with RxJS switch

Flatten a higher order observable with RxJS switch

4:52 rx PRO

To consume the higher order RxJS Observable, we had to do a subscribe inside a subscribe. In this lesson, we will learn a better approach using flattening operators, of which switch() is a common and simple one.

rx tutorial about Conclusion: when to use Subjects

Conclusion: when to use Subjects

2:36 rx

As a conclusion to this course about RxJS Subjects, lets review when and why should you use them.

rx tutorial about ReplaySubject: remembering events from the past

ReplaySubject: remembering events from the past

5:41 rx

A BehaviorSubject can remember the latest value emitted, but what if we wanted Observer B to see all the previous values emitted in the past? We can't do that with BehaviorSubject, but there is ReplaySubject, which allows us to do that. This lessons teaches you everything you need to know about ReplaySubjects.

rx tutorial about Multicast with a selector argument, as a sandbox

Multicast with a selector argument, as a sandbox

7:11 rx

Let's explore a different use of the multicast() operator in RxJS, where you can provide a selector function as a sandbox where the shared Observable is available.

rx tutorial about Reusable multicasting with Subject factories

Reusable multicasting with Subject factories

5:19 rx

The way we use publish() (or multicast with an RxJS Subject) makes the shared Observable not reusable if the shared execution happens to complete or emit an error. In this lesson we will see how to use a simple Subject factory function in order to create a new Subject, one for each shared execution, whenever connect() is called.

rx tutorial about Multicasting shortcuts: publish() and variants

Multicasting shortcuts: publish() and variants

4:21 rx

Because using multicast with a new Subject is such a common pattern, there is a shortcut in RxJS for this: the publish() operator. This lesson introduces publish() and its variants publishReplay(), publishBehavior(), publishLast(), share(), and shows how they simplify the creation of multicasted Observables.

rx tutorial about Stopping a shared observable execution

Stopping a shared observable execution

2:39 rx

ConnectableObservable has the connect() method to conveniently dictate the start of the shared execution of the source Observable. However, we need a mechanism to dictate the stop of the shared execution, otherwise a leak happens. This lesson will teach you how to do that, and it's all about Subscriptions.

rx tutorial about RefCount: automatically starting and stopping an execution

RefCount: automatically starting and stopping an execution

4:45 rx

With the connect() method on a ConnectableObservable, the programmer is responsible for avoiding leaked executions of shared RxJS Observables. This lesson will teach you about refCount(), a handy operator that creates an automatically connected Observable, to avoid manually using connect().

rx tutorial about Connection operator: multicast and connect

Connection operator: multicast and connect

5:14 rx

We have seen how Subjects are useful for sharing an execution of an RxJS observable to multiple observers. However, this technique requires some laborious setting up. In this lesson we will learn about the multicast() operator which helps solve the same problem with less code, and with a neater API.

rx tutorial about Using a Subject as an Event Bus

Using a Subject as an Event Bus

3:57 rx

Every Subject is an Observer, meaning we can freely use the Observer methods next(), error(), complete() to manually send events to the Subject. This lesson will teach you how to use a Subject as an Event Bus through the Observer methods.

rx tutorial about BehaviorSubject: representing a value over time

BehaviorSubject: representing a value over time

3:31 rx

Whenever we have multiple observers sharing the same execution, some of those observers may arrive "too late". This lesson will teach you how and when to use a BehaviorSubject to mitigate that problem.

rx tutorial about AsyncSubject: representing a computation that yields a final value

AsyncSubject: representing a computation that yields a final value

4:02 rx

This lesson will teach you about AsyncSubject, another type of Subject with some replaying logic inside. We will also look at some use cases for this peculiar RxJS subject variant.

rx tutorial about Subject: an Observable and Observer hybrid

Subject: an Observable and Observer hybrid

4:06 rx

This lesson teaches you how a Subject is simply a hybrid of Observable and Observer which can act as a bridge between the source Observable and multiple observers, effectively making it possible for multiple observers to share the same Observable execution.

rx tutorial about An Observable execution may only have one Observer

An Observable execution may only have one Observer

2:13 rx

Let's remind ourselves of a fundamental behavior of the Observable in RxJS, which is: each Observable execution has only one Observer. This means we cannot directly share one single Observable execution to multiple Observers.

rx tutorial about More operators and conclusion

More operators and conclusion

1:06 rx PRO

Let's recap the categories of operators covered by the series. This lesson also shows what was not taught, and what comes next as learning material.

rx tutorial about Error handling operator: retry and retryWhen

Error handling operator: retry and retryWhen

4:01 rx PRO

Besides catch, the other commonly used error handling operator is retry(). This lessons teaches how retry() and retryWhen() detect errors and how they re-subscribe to the source, besides highlighting its real-world applications.

rx tutorial about Transformation operator: repeat

Transformation operator: repeat

1:28 rx PRO

Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson we learn how repeat works.

rx tutorial about Error handling operator: catch

Error handling operator: catch

5:24 rx PRO

Most of the common RxJS operators are about transformation, combination or filtering, but this lesson is about a new category, error handling operators, and its most important operator: catch().

rx tutorial about Filtering operators: distinct and distinctUntilChanged

Filtering operators: distinct and distinctUntilChanged

4:34 rx PRO

Operator distinct() and its variants are an important type of Filtering operator. This lessons shows how they work and in what cases are they useful.

rx tutorial about Filtering operators: throttle and throttleTime

Filtering operators: throttle and throttleTime

2:48 rx PRO

Debounce is known to be a rate-limiting operator, but it's not the only one. This lessons introduces you to throttleTime and throttle, which only drop events (without delaying them) to accomplish rate limiting.

rx tutorial about Transformation operators: debounce and debounceTime

Transformation operators: debounce and debounceTime

5:21 rx PRO

Debounce and debounceTime operators are similar to delayWhen and delay, with the difference that they may drop some emissions. This lesson teaches you how debounce works and where is it useful, for instance when building a type-ahead UI.

rx tutorial about Transformation operators: delay and delayWhen

Transformation operators: delay and delayWhen

4:22 rx PRO

This lessons teaches about delay and delayWhen: simple operators that time shift each emission from the source Observable by a specified amount of time.

rx tutorial about Transformation operator: buffer

Transformation operator: buffer

5:17 rx PRO

This lesson will teach you about another horizontal combination operator: buffer and its variants. Buffer groups consecutive values together, emitting the output as an array. The buffer variants and their arguments allow to specify when to close the buffers.

rx tutorial about Transformation operator: scan

Transformation operator: scan

5:21 rx PRO

All of the combination operators take two or more observables as input. These operators may also be alternatively called "vertical combination operators", because of how they work in a marble diagram. Next, we will learn about scan(), which is an important "horizontal combination operator".

rx tutorial about Combination operator: zip

Combination operator: zip

5:10 rx PRO

CombineLatest and withLatestFrom are both AND-style combination operators. In this lesson, we will learn about zip, our last AND-style combinator. It uses the n-th value of each member Observable to produce the n-th output value.

rx tutorial about Combination operator: withLatestFrom

Combination operator: withLatestFrom

4:02 rx PRO

Operator combineLatest is not the only AND-style combinator. In this lesson we will explore withLatestFrom, another AND-style combination operator, and how it works essentially as map() operator, with some combination properties.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?