Beta

Implement Merge operator from RxJS

Description:

Create a basic Merge operator from RxJS library using JavaScript. This operator will combine multiple Observables into a single Observable, emitting values from all source Observables concurrently.

Requirements

  1. Implement the merge operator to combine multiple source Observables into a single Observable.
  2. Ensure that the operator follows RxJS conventions and integrates seamlessly with existing Observables.

Note

The Observable-like class has already been implemented inside the kata. So you are able to use new Observable, pipe, of, interval

Usage example

const source1$ = Observable.of(1, 2, 3);
const source2$ = Observable.of(4, 5, 6);
// Also possible: 
// const source2$ = new Observable(observer => { observer.next(1) });
const merged$ = merge(source1$, source2$);

merged$.subscribe({
  next: value => console.log(value),
  error: err => console.error('Error:', err),
  complete: () => console.log('Completed')
});
// Output: 1 2 3 4 5 6 Completed

Have fun!😀

RxJS
Reactive Programming
Reverse Engineering

Similar Kata:

More By Author:

Check out these other kata created by NuclearGlam

Stats:

CreatedSep 18, 2024
PublishedSep 20, 2024
Warriors Trained12
Total Skips0
Total Code Submissions26
Total Times Completed4
JavaScript Completions4
Total Stars1
% of votes with a positive feedback rating50% of 2
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments2
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • NuclearGlam Avatar
Ad