Operators Flashcards

1
Q

What are combination operators in Rxjs

A

The combination operators allow the joining of information from multiple observables. Order, time, and structure of emitted values is the primary variation among these operators.

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

Some commonly used combinatory operators.

A
CombineLatest
Concat
Merge
StartWith
WithLatestFrom
Zip
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is CombineLatest used for

A

This operator is best used when you have multiple, long-lived observables that rely on each other for some calculation or determination. combineLatest will not emit an initial value until each observable emits at least one value.
For the very first time, all of the values should have emitted at least once, from that point, any change in one of the values will cause the observable to emit

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

Explain Concat operator

A

When multiple observables are used in this method, the

subscription to the subsequent observables will happen only after the previous ones have completed

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

Explain Merge Operator

A

The output isn’t in the same order as subscribed. Whichever emits first will have its value passed to the subscribe method.

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

Explain Start With

A

It takes an initial value and when piped with other observables, the initial value will be the one emitted first

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

Explain WithLatestFrom

A

(Master/Slave)we have source and the value passed to WithLatestFrom.
They are in a kind of Master/Slave relationship. After the slave emits for the first time, master takes over. After that the subscription fires only when the Master changes, with the value of Master and whatever value is available from the Slave at that time

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

Explain Zip Operator

A

(Love Birds)For example:There is a Source 1 and Source 2.When they are zipped and subscribed to, the subscription will yield only when the values in source 1 and source 2 have changed in a pairing fashion.

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

what are Transformative operators

A

Transforming values as they pass through the operator chain is a common task. These operators provide transformation techniques for nearly any use-case you will encounter.

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

Commonly used transformation operators

A
BufferTime
ConcatMap
Map
MergeMap/FlatMap
scan
SwitchMap
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain BufferTime

A

Collect emitted values until provided time has passed, emit as array.

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

Explain ConcatMap

A

ConcatMap subscribes to the inner Observable for you. But unlike switchMap, that unsubscribes from the current Observable if a new Observable comes in, concatMap will not subscribe to the next Observable until the current one completes. The benefit of this is that the order in which the Observables are emitting is maintained

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

Explain Map

A

Similiar to select in C#.

Apply projection with each value from source.

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

Explain MergeMap /FlatMap

A

Used when the order of emission is not important.Similar to Merge in Combinations.
This operator is best used when you wish to flatten an inner observable but want to manually control the number of inner subscriptions.
When we have an outer observable and an inner Observable, we don’t have to call subscribe twice on the outer and the inner values. MergeMap takes care of it for us.It is possible to have multiple active subscriptions at a time with MergeMap

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

Explain Switch Map

A

Switch map will come in handy if you compose a list of filters into a data stream and perform an API call when a filter is changed. If the previous filter changes are still being processed while a new change is already made, it will cancel the previous subscription and start a new subscription on the latest change

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