RxJs Flashcards

1
Q

What is a “stream”?

A

The concept of values/events being emitted(processed) over time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

So what is an Observable in relation to a stream?

A

It facilitates & helps manage that stream over time. Gives methods, helpers to emit/respond to the event(s)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

An Observable must take in what as an argument?

A

A function that defines an Observer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the job of the Observer

A

To “observe” any incoming data over time & handle(error)/emit/manipulate the value then return it.

Short answer: Execute code when a value comes through the steam

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What real-life object best illustrates the concept of observables/streams

A

Think of an observable as a funnel (cone) that receives liquid (a stream of contents/data) over time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What hooks up Observers to an Observable?

A

A subscription - a subscribe method that tells the Observable that it’s being observed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Remember a stream can be ongoing over time how do you stop an observable?

A

Observer.complete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

An observer can emit/return data overtime w/ what method?

A

Observer.next()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

An observer can handle an error w/ data coming in w/ what method?

A

Observer.error()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The power of RxJs is by having methods out of the box that does what? What are these methods called?

A

Operators - they can manipulate/transform the values as they arrive through the funnel(stream)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

RxJs is functional in the sense that you get an input => routed to an expected output that can have operators chained one after another

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When do you define & chain operators?

A

Before the subscription (subscribing w/ an observer)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Operators manipulate the data but return what?

A

Another observable w/ the new stream of data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A subject is an out of the box Observable you subscribe to in order to what?

A

EventEmitter that emits the value(s) passed over time to other observables.

Eg: var subject = new Subject() // -> Observable

subject.subscribe() // values: 1, 2, 3, 4, 5
Later subscription….
subject.subscribe() // values: 3, 4, 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A subject is a “multicast” observable that does what when subscribed to?

A

Instead of invoking it registers the subscribed observer to a list (registry) of other observers that will receive updates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the subject type: BehaviorSubject do?

A

It immediately gives the recently subscribed observer the current data or previously emitted value before receiving new data.

17
Q

What does the subject type: ReplaySubject do?

A

It immediately replays in order all previous values to a new subscriber or observer before it receives new data.