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

Commit 925abd5

Browse files
Merge pull request #187 from ashwin-sureshkumar/issue-105
docs(operators): add documentation for throttleTime
2 parents c551eca + 1bdae81 commit 925abd5

File tree

1 file changed

+70
-2
lines changed

1 file changed

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

33
export const throttleTime: OperatorDoc = {
4-
'name': 'throttleTime',
5-
'operatorType': 'filtering'
4+
name: 'throttleTime',
5+
operatorType: 'filtering',
6+
signature:
7+
'public throttleTime(duration: number, scheduler: Scheduler): Observable<T>',
8+
parameters: [
9+
{
10+
name: 'duration',
11+
type: 'number',
12+
attribute: '',
13+
description: `Time to wait before emitting another value after emitting the last value,
14+
measured in milliseconds or the time unit determined internally by the optional scheduler.`
15+
},
16+
{
17+
name: 'scheduler',
18+
type: 'Scheduler',
19+
attribute: 'optional default:sync',
20+
description:
21+
'The IScheduler to use for managing the timers that handle the sampling.'
22+
}
23+
],
24+
marbleUrl: 'http://reactivex.io/rxjs/img/throttleTime.png',
25+
shortDescription: {
26+
description: `Emits a value from the source Observable,
27+
then ignores subsequent source values for duration milliseconds, then repeats this process.`,
28+
extras: [
29+
{
30+
type: 'Tip',
31+
text: `
32+
Lets a value pass, then ignores source values for the next duration milliseconds.
33+
`
34+
}
35+
]
36+
},
37+
walkthrough: {
38+
description: `
39+
<p>
40+
throttleTime emits the source Observable values on the output Observable when its internal timer is disabled,
41+
and ignores source values when the timer is enabled. Initially, the timer is disabled.
42+
</p>
43+
<p>
44+
As soon as the first source value arrives, it is forwarded to the output Observable, and then the timer is enabled.
45+
</p>
46+
<p>
47+
After duration milliseconds (or the time unit determined internally by the optional scheduler) has passed, the timer is disabled,
48+
and this process repeats for the next source value. Optionally takes a IScheduler for managing timers.
49+
</p>
50+
`
51+
},
52+
examples: [
53+
{
54+
name:
55+
'Emit X position of mouse clicks at a rate of at most one click per second',
56+
code: `
57+
const clicks = Rx.Observable.fromEvent(document, 'click');
58+
const result = clicks.throttleTime(1000);
59+
result.subscribe(x => console.log(x.clientX));
60+
`,
61+
externalLink: {
62+
platform: 'JSBin',
63+
url: 'http://jsbin.com/nefefeb/embed?js,console,output'
64+
}
65+
}
66+
],
67+
relatedOperators: [
68+
'auditTime',
69+
'debounceTime',
70+
'delay',
71+
'sampleTime',
72+
'throttle'
73+
]
674
};

0 commit comments

Comments
 (0)