0
0
Angularframework~10 mins

combineLatest and forkJoin for combining in Angular - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the operator that emits the latest values from multiple observables.

Angular
import { [1] } from 'rxjs';
Drag options to blanks, or click blank then click option'
AcombineLatest
BforkJoin
Cmap
Dfilter
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing forkJoin instead of combineLatest
Importing unrelated operators like map or filter
2fill in blank
medium

Complete the code to import the operator that waits for all observables to complete and then emits their last values.

Angular
import { [1] } from 'rxjs';
Drag options to blanks, or click blank then click option'
AforkJoin
BcombineLatest
Cmerge
Dconcat
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing combineLatest instead of forkJoin
Confusing merge or concat with forkJoin
3fill in blank
hard

Fix the error in the code by completing the operator used to combine observables that emits only when all complete.

Angular
forkJoin([obs1, obs2]).subscribe(values => {
  console.log(values);
});

// The operator used is [1]
Drag options to blanks, or click blank then click option'
AcombineLatest
Bconcat
CforkJoin
Dmerge
Attempts:
3 left
💡 Hint
Common Mistakes
Using combineLatest instead of forkJoin
Using merge which emits values as they come
4fill in blank
hard

Fill both blanks to create a combined observable that emits the latest values from obsA and obsB.

Angular
const combined$ = [1]([obsA, obsB]);
combined$.subscribe(([valA, valB]) => {
  console.log(valA, valB);
});
Drag options to blanks, or click blank then click option'
Aconcat
BforkJoin
Cmerge
DcombineLatest
Attempts:
3 left
💡 Hint
Common Mistakes
Using forkJoin which waits for completion
Using merge which merges emissions but does not combine latest values
5fill in blank
hard

Fill all three blanks to create a forkJoin that waits for obsX, obsY, and obsZ to complete and then logs their last values.

Angular
forkJoin([[1], [2], [3]]).subscribe(results => {
  console.log(results);
});
Drag options to blanks, or click blank then click option'
AobsX
BobsY
CobsZ
DobsA
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong observables or missing one
Confusing forkJoin with combineLatest here