diff --git a/src/app/team/team.module.ts b/src/app/team/team.module.ts index f940a1b2..9c4dca16 100644 --- a/src/app/team/team.module.ts +++ b/src/app/team/team.module.ts @@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common'; import { MatCardModule, MatButtonModule, - MatIconModule, + MatIconModule } from '@angular/material'; import { TeamRoutingModule } from './team-routing.module'; diff --git a/src/app/team/team.service.spec.ts b/src/app/team/team.service.spec.ts index 42ce51ec..d12e4077 100644 --- a/src/app/team/team.service.spec.ts +++ b/src/app/team/team.service.spec.ts @@ -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(); + }) + ); }); diff --git a/src/operator-docs/filtering/index.ts b/src/operator-docs/filtering/index.ts index 93d93239..c891a1d4 100644 --- a/src/operator-docs/filtering/index.ts +++ b/src/operator-docs/filtering/index.ts @@ -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'; @@ -25,6 +26,7 @@ export const FILTERING_OPERATORS = [ ignoreElements, last, sample, + sampleTime, single, skip, skipUntil, diff --git a/src/operator-docs/filtering/sample.ts b/src/operator-docs/filtering/sample.ts index 50c9666e..7064dc60 100644 --- a/src/operator-docs/filtering/sample.ts +++ b/src/operator-docs/filtering/sample.ts @@ -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 sampleTime, + but samples whenever the notifier Observable emits something. + ` } ] }, walkthrough: { description: `
- Whenever the notifier Observable emits a value or completes, + Whenever the notifier 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.
- The notifier is subscribed to as soon as the output Observable is subscribed. + The notifier is subscribed to as soon as the output Observable is subscribed.
` }, diff --git a/src/operator-docs/filtering/sampleTime.ts b/src/operator-docs/filtering/sampleTime.ts new file mode 100644 index 00000000..5ae0eeaf --- /dev/null +++ b/src/operator-docs/filtering/sampleTime.ts @@ -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: ` ++ sampleTime 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 period + milliseconds (or the time unit defined by the optional scheduler argument). + The sampling starts as soon as the output Observable is subscribed. +
+ ` + }, + 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: [] +};