Fireship · @fireship
Top 7 RxJS Concepts for Angular Developers
Uploaded July 21, 2017 · Length 7:19
Summary
rxjs library concepts for angular developers, including combine latest, static methods, subscriptions, mapping observables, switch map, combine latest, and behavior subjects.
- rxjs concepts
- angular developers
- rxjs library
- combine latest operator
- static methods rxjs
- angular subscriptions
- observable mapping
- switch map operator
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
rxjs is a huge library with a very steep
- 0:03
learning curve in this episode I'm going
- 0:05
to talk about a few key Concepts that
- 0:07
are specific to angular Firebase
- 0:09
developers I believe it's best to focus
- 0:12
on what you actually need to learn
- 0:13
rather than try to master the entire
- 0:15
rxjs library to do this I've created a
- 0:18
simple component that uses the angular
- 0:20
Fire 2 package to retrieve cats and dogs
- 0:23
from Firebase cats and dogs each have
- 0:25
their own collection and there's another
- 0:27
collection for humans which represent
- 0:29
the owner of a given pet your component
- 0:32
should look something like this we
- 0:33
import the angular fire database and
- 0:35
then inject it in the Constructor when
- 0:38
using rxjs and angular you only import
- 0:40
the methods and classes that you need in
- 0:43
rxjs there are two types of methods
- 0:45
static and instance in this first
- 0:47
example we use an instance method
- 0:49
combine latest so we create two
- 0:51
instances of an
- 0:53
observable then we can use that operator
- 0:55
on the observable instance itself notice
- 0:57
how the method was imported from ad SL
- 1:00
operator the operator directory contains
- 1:03
all of the instance methods it's not
- 1:05
important to know at this point but
- 1:06
using combined latest will result in an
- 1:09
observable array of two strings now
- 1:11
let's accomplish the same thing using a
- 1:14
static method to obtain the static
- 1:16
method we import from the add/
- 1:18
observable
- 1:19
directory instead of calling the method
- 1:21
on an instance we call it on the
- 1:23
observable class itself and then we pass
- 1:25
the two observables to it as arguments
- 1:28
in rxjs some methods are only instance
- 1:30
others are only static and some overlap
- 1:32
for both now let's talk about
- 1:35
subscriptions that's how you actually
- 1:36
extract data from observables there are
- 1:39
two main ways to do this in angular you
- 1:40
can either subscribe in the component
- 1:42
typescript or in the component HTML in
- 1:45
this example we will subscribe to cats
- 1:47
in the HTML and dogs in the component
- 1:50
typescript notice how cats are a
- 1:52
Firebase list observable and dogs are
- 1:54
just a regular array calling DB list
- 1:57
will return in observable from the
- 1:59
Firebase database for cats we just keep


