Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documentation for filterResultErr() rxjs operator #147

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/reference/api/rxjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,21 @@ test$.subscribe((result) => {

#### filterResultErr

Converts an `Observable<Result<T, E>>` to an `Observble<T>` by filtering out the Oks and mapping to the error values.
Converts an `Observable<Result<T, E>>` to an `Observable<E>` by filtering out the Oks and mapping to the error values.

```typescript
import { of, Observable } from 'rxjs';
import { Ok, Err, Result } from 'ts-results-es';
import { filterResultOk } from 'ts-results-es/rxjs-operators';
import { filterResultErr } from 'ts-results-es/rxjs-operators';

const obs$: Observable<Result<number, Error>> = of(new Ok(5), new Err(new Error('uh oh')));

const test$ = obs$.pipe(filterResultOk()); // Has type Observable<number>
const test$ = obs$.pipe(filterResultErr()); // Has type Observable<Error>

test$.subscribe((result) => {
console.log('Got number: ' + result);
console.log('Got error: ' + result);
});

// Logs the following:
// Got number: 5
// Got error: uh oh
```
10 changes: 5 additions & 5 deletions docs/reference/api/rxjs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,25 @@ filtering out the Errs and mapping to the Ok values.
``filterResultErr()``
---------------------

Converts an ``Observable<Result<T, E>>`` to an ``Observble<T>`` by
Converts an ``Observable<Result<T, E>>`` to an ``Observble<E>`` by
filtering out the Oks and mapping to the error values.

.. code:: typescript

import { of, Observable } from 'rxjs';
import { Ok, Err, Result } from 'ts-results-es';
import { filterResultOk } from 'ts-results-es/rxjs-operators';
import { filterResultErr } from 'ts-results-es/rxjs-operators';

const obs$: Observable<Result<number, Error>> = of(new Ok(5), new Err(new Error('uh oh')));

const test$ = obs$.pipe(filterResultOk()); // Has type Observable<number>
const test$ = obs$.pipe(filterResultErr()); // Has type Observable<Error>

test$.subscribe((result) => {
console.log('Got number: ' + result);
console.log('Got error: ' + result);
});

// Logs the following:
// Got number: 5
// Got error: uh oh


.. _Reactive Extensions for JavaScript: https://rxjs.dev/
Loading