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

docs(operators): add documentation for sample & sampleTime #207

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cfbe5be
docs(operators): add documentation for sample
hardikpthv Dec 14, 2017
cc7666c
fix(operators): add markdown code to highlight keyword and replace va…
hardikpthv Dec 14, 2017
cdee0d0
docs(operators): add documentation for sampleTime
hardikpthv Dec 14, 2017
5072a36
Merge branch 'master' into iss-192
sumitarora Dec 15, 2017
17e6cb8
fix(operators): update code snippets
hardikpthv Dec 16, 2017
2865cb3
fix(operators): add link to existing operator
hardikpthv Dec 16, 2017
4c80ee7
Merge branch 'master' into iss-192
hardikpthv Dec 16, 2017
ad3cce0
Merge branch 'master' into iss-192
hardikpthv Dec 30, 2017
c442d6f
fix(operators): add link to existing operator and markdown to keywords
hardikpthv Dec 30, 2017
829ac13
Merge branch 'master' into iss-192
hardikpthv Jan 7, 2018
5dfd268
Merge branch 'master' into iss-192
hardikpthv Jan 9, 2018
2b814f3
Merge branch 'master' into iss-192
hardikpthv Jan 11, 2018
e81780c
Merge branch 'master' into iss-192
hardikpthv Jan 14, 2018
0548cc6
Merge branch 'master' into iss-192
hardikpthv Jan 27, 2018
7c09379
Merge branch 'master' into iss-192
hardikpthv Feb 5, 2018
abcfc64
Merge branch 'master' into iss-192
hardikpthv Feb 6, 2018
1a7cd49
Merge branch 'master' into iss-192
hardikpthv Mar 1, 2018
7c69716
Merge branch 'master' into iss-192
sumitarora Mar 10, 2018
91f9546
Merge branch 'master' into iss-192
hardikpthv Apr 1, 2018
c43c502
fix(operators): update code snippet
hardikpthv Apr 1, 2018
4160552
fix(operators): remove generic
hardikpthv Apr 1, 2018
82e67e4
Merge branch 'master' into iss-192
hardikpthv Apr 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/team/team.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
import {
MatCardModule,
MatButtonModule,
MatIconModule,
MatIconModule
} from '@angular/material';

import { TeamRoutingModule } from './team-routing.module';
Expand Down
9 changes: 6 additions & 3 deletions src/app/team/team.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ describe('TeamService', () => {
});
});

it('should be created', inject([TeamService], (service: TeamService) => {
expect(service).toBeTruthy();
}));
it(
'should be created',
inject([TeamService], (service: TeamService) => {
expect(service).toBeTruthy();
})
);
});
2 changes: 2 additions & 0 deletions src/operator-docs/filtering/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { first } from './first';
import { ignoreElements } from './ignoreElements';
import { last } from './last';
import { sample } from './sample';
import { sampleTime } from './sampleTime';
import { single } from './single';
import { skip } from './skip';
import { skipUntil } from './skipUntil';
Expand All @@ -25,6 +26,7 @@ export const FILTERING_OPERATORS = [
ignoreElements,
last,
sample,
sampleTime,
single,
skip,
skipUntil,
Expand Down
9 changes: 6 additions & 3 deletions src/operator-docs/filtering/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ export const sample: OperatorDoc = {
extras: [
{
type: 'Tip',
text: `It's like sampleTime, but samples whenever the notifier Observable emits something.`
text: `
It's like <a href="#/operators/sampleTime" class="markdown-code">sampleTime</a>,
but samples whenever the notifier Observable emits something.
`
}
]
},
walkthrough: {
description: `
<p>
Whenever the notifier Observable emits a value or completes,
Whenever the <span class="markdown-code">notifier</span> Observable emits a value or completes,
sample looks at the source Observable and emits whichever value it has most recently emitted since the previous sampling,
unless the source has not emitted anything since the previous sampling.
</p>
<p>
The notifier is subscribed to as soon as the output Observable is subscribed.
The <span class="markdown-code">notifier</span> is subscribed to as soon as the output Observable is subscribed.
</p>
`
},
Expand Down
83 changes: 83 additions & 0 deletions src/operator-docs/filtering/sampleTime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { OperatorDoc } from '../operator.model';

export const sampleTime: OperatorDoc = {
name: 'sampleTime',
operatorType: 'filtering',
signature:
'public sampleTime(period: number, scheduler: Scheduler): Observable',
marbleUrl: 'http://reactivex.io/rxjs/img/sampleTime.png',
parameters: [
{
name: 'period',
type: 'number',
attribute: '',
description: `The sampling period expressed in milliseconds or the time unit determined internally by the optional scheduler.`
},
{
name: 'scheduler',
type: 'Scheduler',
attribute: 'optional default: async',
description: `The IScheduler to use for managing the timers that handle the sampling.`
}
],
shortDescription: {
description: `Emits the most recently emitted value from the source Observable within periodic time intervals.`,
extras: [
{
type: 'Tip',
text: `Samples the source Observable at periodic time intervals, emitting what it samples.`
}
]
},
walkthrough: {
description: `
<p>
<span class="markdown-code">sampleTime</span> periodically looks at the source
Observable and emits whichever value it has most recently emitted since the previous
sampling, unless the source has not emitted anything since the previous sampling.
The sampling happens periodically in time every <span class="markdown-code">period</span>
milliseconds (or the time unit defined by the optional <span class="markdown-code">scheduler</span> argument).
The sampling starts as soon as the output Observable is subscribed.
</p>
`
},
examples: [
{
name: 'Every second, emit the most recent click at most once',
code: `
import { fromEvent } from "rxjs/observable/fromEvent";
import { sampleTime } from "rxjs/operators";

const clicks = fromEvent(document, "click");
const result = clicks.pipe(sampleTime(1000));
result.subscribe(x => console.log(x));

/*
Example console output
[object MouseEvent] {
altKey: false,
AT_TARGET: 2,
bubbles: true,
BUBBLING_PHASE: 3,
button: 0,
buttons: 0,
cancelable: true,
.... //Entire object properties
}
*/
`,
externalLink: {
platform: 'JSBin',
url: 'http://jsbin.com/hohulon/embed?js,console,output'
}
}
],
relatedOperators: [
'auditTime',
'debounceTime',
'delay',
'sample',
'throttleTime'
],
additionalResources: []
};