Skip to content

Commit

Permalink
docs(single): Updated docs for single with description and example (#… (
Browse files Browse the repository at this point in the history
ReactiveX#4623)

* docs(single): Updated docs for single with description and example (ReactiveX#4616)

Updated docs for single with description and example

* docs(single): Updated docs for single with description and example (ReactiveX#4616)

Updated docs for  the requested changes
  • Loading branch information
weitalu authored and BioPhoton committed May 15, 2019
1 parent b509e1c commit 7a4a6e7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/internal/operators/single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,34 @@ import { Observer, MonoTypeOperatorFunction, TeardownLogic } from '../types';
* items, notify of an IllegalArgumentException or NoSuchElementException respectively. If the source Observable
* emits items but none match the specified predicate then `undefined` is emitted.
*
* <span class="informal">Like {@link first}, but emit with error notification if there is more than one value.</span>
* ![](single.png)
*
* ## Example
* emits 'error'
* ```ts
* import { range } from 'rxjs';
* import { single } from 'rxjs/operators';
*
* const numbers = range(1,5).pipe(single());
* numbers.subscribe(x => console.log('never get called'), e => console.log('error'));
* // result
* // 'error'
* ```
*
* emits 'undefined'
* ```ts
* import { range } from 'rxjs';
* import { single } from 'rxjs/operators';
*
* const numbers = range(1,5).pipe(single(x => x === 10));
* numbers.subscribe(x => console.log(x));
* // result
* // 'undefined'
* ```
*
* @see {@link first}
*
* @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
* callback if the Observable completes before any `next` notification was sent.
* @param {Function} predicate - A predicate function to evaluate items emitted by the source Observable.
Expand Down

0 comments on commit 7a4a6e7

Please sign in to comment.