concat example does not work with an array of Observables
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
Documentation Related To Component:
concat static operator in src/internal/observable/concat.ts
Please check those that apply
- typo
- documentation doesn't exist
- documentation needs clarification
- error(s) in example
- needs example
Description Of The Issue
The exemple Concatenate an array of 3 Observables in the concat documentation page at https://rxjs.dev/api/index/function/concat does not output the expected result.
Expected result
// results in the following:
// (Prints to console sequentially)
// -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9
// -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5
// -500ms-> 0 -500ms-> 1 -500ms-> ... 9
Current result in Stackblitz
// Observable {_isScalar: false, source: {…}, operator: {…}}
// Observable {_isScalar: false, source: {…}, operator: {…}}
// Observable {_isScalar: false, source: {…}, operator: {…}}
Additional information
Passing the array with the rest operator instead of the array itself output the expected result.
const result = concat([timer1, timer2, timer3]); // note that array is passed // does not work
const result = concat(...[timer1, timer2, timer3]); // note that array is passed // works
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the concat documentation page at https://rxjs.dev/api/index/function/concat and inspect the example titled "Concatenate an array of 3 Observables"; the issue also identifies src/internal/observable/concat.ts as the component. Verify the example in Stackblitz and update the documented usage so it produces the three sequential timer outputs rather than Observable objects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100