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

Commit b2741a7

Browse files
authored
Merge branch 'master' into feature/89-operator-debounceTime
2 parents 177bb76 + 6920eb6 commit b2741a7

File tree

1 file changed

+61
-3
lines changed

1 file changed

+61
-3
lines changed
Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,64 @@
1-
import { OperatorDoc } from '../operator.model';
1+
import { OperatorDoc } from "../operator.model";
22

33
export const debounce: OperatorDoc = {
4-
'name': 'debounce',
5-
'operatorType': 'filtering'
4+
name: "debounce",
5+
operatorType: "filtering",
6+
signature:
7+
"public debounce(durationSelector: function(value: T): SubscribableOrPromise): Observable",
8+
marbleUrl: "http://reactivex.io/rxjs/img/debounce.png",
9+
parameters: [
10+
{
11+
name: "durationSelector",
12+
type: "function(value: T): SubscribableOrPromise",
13+
attribute: "",
14+
description: `A function that receives a value from the source Observable
15+
, for computing the timeout duration for each source value, returned as an Observable or a Promise.`
16+
}
17+
],
18+
shortDescription: {
19+
description: `Emits a value from the source Observable only after a particular time span determined
20+
by another Observable has passed without another source emission.`,
21+
extras: [
22+
{
23+
type: "Tip",
24+
text: `
25+
It's like debounceTime, but the time span of emission silence is determined by a second Observable.
26+
`
27+
}
28+
]
29+
},
30+
walkthrough: {
31+
description: `
32+
<p>
33+
debounce delays values emitted by the source Observable,
34+
but drops previous pending delayed emissions if a new value arrives on the source Observable.
35+
This operator keeps track of the most recent value from the source Observable,
36+
and spawns a duration Observable by calling the durationSelector function.
37+
The value is emitted only when the duration Observable emits a value or completes,
38+
and if no other value was emitted on the source Observable since the duration Observable was spawned.
39+
If a new value appears before the duration Observable emits,
40+
the previous value will be dropped and will not be emitted on the output Observable.
41+
</p>
42+
<p>
43+
Like debounceTime, this is a rate-limiting operator, and also a delay-like operator
44+
since output emissions do not necessarily occur at the same time as they did on the source Observable.
45+
</p>
46+
`
47+
},
48+
examples: [
49+
{
50+
name: "Emit the most recent click after a burst of clicks",
51+
code: `
52+
var clicks = Rx.Observable.fromEvent(document, 'click');
53+
var result = clicks.debounce(() => Rx.Observable.interval(1000));
54+
result.subscribe(x => console.log(x));
55+
`,
56+
externalLink: {
57+
platform: "JSBin",
58+
url: "http://jsbin.com/renayeqatu/1/edit?js,console,output"
59+
}
60+
}
61+
],
62+
relatedOperators: ["debounceTime", "audit", "delayWhen", "throttle"],
63+
additionalResources: []
664
};

0 commit comments

Comments
 (0)