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

Commit cc551d3

Browse files
authored
Merge pull request #218 from natmegs/docs-operator-delay
docs(operators): add documentation for operator delay
2 parents ad6b74c + 997dcf6 commit cc551d3

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed

src/operator-docs/utility/delay.ts

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

33
export const delay: OperatorDoc = {
4-
'name': 'delay',
5-
'operatorType': 'utility'
4+
name: 'delay',
5+
operatorType: 'utility',
6+
signature:
7+
'public delay(delay: number | Date, scheduler: Scheduler): Observable',
8+
parameters: [
9+
{
10+
name: 'delay',
11+
type: 'number | Date',
12+
attribute: '',
13+
description: `The delay duration in milliseconds (a number) or a Date until which the
14+
emission of the source items is delayed.`
15+
},
16+
{
17+
name: 'scheduer',
18+
type: 'Scheduler',
19+
attribute: '',
20+
description:
21+
'The IScheduler to use for managing the timers that handle the time-shift for each item.'
22+
}
23+
],
24+
useInteractiveMarbles: true,
25+
marbleUrl: 'http://reactivex.io/rxjs/img/delay.png',
26+
shortDescription: {
27+
description: `
28+
Delays the emission of items from the source Observable by a given timeout or until a given Date.
29+
`,
30+
extras: []
31+
},
32+
walkthrough: {
33+
description: `
34+
<p>
35+
If the delay argument is a Number, this operator time shifts the source Observable by that amount
36+
of time expressed in milliseconds. The relative time intervale between the values are preserved.
37+
</p>
38+
<p>
39+
If the delay argument is a Date, this operator time shifts the start of the Observable execution
40+
until the given date occurs.
41+
</p>
42+
`
43+
},
44+
examples: [
45+
{
46+
name: 'Delay each click by one second',
47+
code: `
48+
const clicks = Rx.Observable.fromEvent(document, 'click').mapTo('click');;
49+
const delayedClicks = clicks.delay(1000);
50+
delayedClicks.subscribe(x => console.log(x));
51+
`,
52+
externalLink: {
53+
platform: 'JSBin',
54+
url: 'http://jsbin.com/howeziyoma/embed?js,console,output'
55+
}
56+
},
57+
{
58+
name: 'Delay all clicks until a future date happens',
59+
code: `
60+
const clicks = Rx.Observable.fromEvent(document, 'click');
61+
const date = new Date('March 15, 2050 12:00:00');
62+
const delayedClicks = clicks.delay(date);
63+
delayedClicks.subscribe(x => console.log(x));
64+
`,
65+
externalLink: {
66+
platform: 'JSBin',
67+
url: 'http://jsbin.com/cozogifayu/embed?js,console,output'
68+
}
69+
}
70+
],
71+
relatedOperators: ['debounceTime', 'delayWhen'],
72+
additionalResources: []
673
};

0 commit comments

Comments
 (0)