IntroToRx: Creating Observable Sequences
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 70/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- documentation
Research direction
Open Rx.NET/Documentation/IntroToRx/03_CreatingObservableSequences.md and locate the Observable.Create section linked in the issue. Check the file-reading snippet's cancellation condition, correct it so reading continues until cancellation, and verify the documented code matches the supplied corrected example.
Written by the indexing model from the issue text.
Description
Bug
Which library version?
The issue is in the documentation of the library, not in a specific version of the library itself.
What are the platform(s), environment(s) and related component version(s)?
Not applicable.
What is the use case or problem?
There is a typo in the documentation code snippet for reading file lines using Observable.Create.
https://github.com/dotnet/reactive/blob/main/Rx.NET/Documentation/IntroToRx/03_CreatingObservableSequences.md#observablecreate
What is the expected outcome?
The code snippet should correctly handle the cancellation token in the while loop.
What is the actual outcome?
The current code uses while (cancellationToken.IsCancellationRequested) which will break the loop when the cancellation is requested. It should use while (!cancellationToken.IsCancellationRequested) instead.
What is the stacktrace of the exception(s) if any?
Not applicable.
Do you have a code snippet or project that reproduces the problem?
Yes, here is the corrected code snippet:
IObservable<string> ReadFileLines(string path) =>
Observable.Create<string>(async (observer, cancellationToken) =>
{
using (StreamReader reader = File.OpenText(path))
{
while (!cancellationToken.IsCancellationRequested)
{
string? line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
if (line is null)
{
break;
}
observer.OnNext(line);
}
observer.OnCompleted();
}
});
- Dominant language
- C#
- Stars
- 7.2k
- Forks
- 798
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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.
More from dotnet/reactive
-
[area] Rx
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
[area] Ix
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
[area] AsyncRx
Difficulty 5/5 Over a week Newbie friendliness 42/100
-
[area] Rx
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
[area] Rx
Difficulty 5/5 Over a week Newbie friendliness 30/100
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·