Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Commit 6d8a3c2

Browse files
docs(operators): add documentation for operator empty
Add initial version of documentation for creation operator 'empty'.
1 parent 03bc259 commit 6d8a3c2

File tree

1 file changed

+66
-2
lines changed

1 file changed

+66
-2
lines changed
Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,70 @@
11
import { OperatorDoc } from '../operator.model';
22

33
export const empty: OperatorDoc = {
4-
'name': 'empty',
5-
'operatorType': 'creation'
4+
name: 'empty',
5+
operatorType: 'creation',
6+
signature: 'public empty<T>(scheduler?: IScheduler): Observable<T>',
7+
parameters: [
8+
{
9+
name: 'scheduler',
10+
type: 'IScheduler',
11+
attribute: 'optional',
12+
description:
13+
'Allows scheduling the emission of the complete notification.'
14+
}
15+
],
16+
marbleUrl: 'http://reactivex.io/rxjs/img/empty.png',
17+
shortDescription: {
18+
description:
19+
'Creates an Observable that emits no items to the Observer' +
20+
' and immediately emits a complete notification.'
21+
},
22+
walkthrough: {
23+
description: `This static operator is useful for creating a simple
24+
Observable that only emits the complete notification. It can be used for
25+
composing with other Observables`
26+
},
27+
examples: [
28+
{
29+
name: 'Observable completes immediately',
30+
code: `const observable = Rx.Observable.empty();
31+
const subscription = observable.subscribe({
32+
next: () => console.log('next'), // does not log anything
33+
complete: () => console.log('complete'), // logs 'complete'
34+
});`,
35+
externalLink: {
36+
platform: 'JSBin',
37+
url: 'http://jsbin.com/hojacunecu/1/edit?js,console,output'
38+
}
39+
},
40+
{
41+
name: 'Observable emits initial value then completes',
42+
code: `const observable = Rx.Observable.empty().startWith('initial value');
43+
const subscription = observable.subscribe({
44+
next: (val) => console.log(\`next: \${val}\`), // logs 'next: initial value'
45+
complete: () => console.log('complete'), // logs 'complete'
46+
});`,
47+
externalLink: {
48+
platform: 'JSBin',
49+
url: 'http://jsbin.com/tubonoradi/1/edit?js,console,output'
50+
}
51+
},
52+
{
53+
name: `Map and flatten only odd numbers to the sequence 'ax', 'bx', 'cx'`,
54+
code: `const source = Rx.Observable.of(1, 2, 3, 4, 5, 6, 7, 8, 9);
55+
const result = source.mergeMap(
56+
x => x % 2 === 1 ? Rx.Observable.of(\`a\${x}\`, \`b\${x}\`, \`c\${x}\`) :
57+
Rx.Observable.empty()
58+
);
59+
const subscription = result.subscribe({
60+
next: (x) => console.log(x), // logs result values
61+
complete: () => console.log('complete'), // logs 'complete'
62+
});`,
63+
externalLink: {
64+
platform: 'JSBin',
65+
url: 'http://jsbin.com/qazabojiri/edit?js,console,output'
66+
}
67+
}
68+
],
69+
relatedOperators: ['create', 'of', 'throw']
670
};

0 commit comments

Comments
 (0)