Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(timestamp): add short-description, description and example #4699

Merged
merged 1 commit into from
Apr 16, 2019
Merged
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions src/internal/operators/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ import { OperatorFunction, SchedulerLike, Timestamp as TimestampInterface } from
import { map } from './map';

/**
* Attaches a timestamp to each item emitted by an observable indicating when it was emitted
*
* The `timestamp` operator maps the *source* observable stream to an object of type
* `{value: T, timestamp: R}`. The properties are generically typed. The `value` property contains the value
* and type of the *source* observable. The `timestamp` is generated by the schedulers `now` function. By
* default it uses the *async* scheduler which simply returns `Date.now()` (milliseconds since 1970/01/01
* 00:00:00:000) and therefore is of type `number`.
*
* ![](timestamp.png)
*
* ## Example
*
* In this example there is a timestamp attached to the documents click event.
*
* ```ts
* import { fromEvent } from 'rxjs';
* import { timestamp } from 'rxjs/operators';
*
* const clickWithTimestamp = fromEvent(document, 'click').pipe(
* timestamp()
* );
*
* // Emits data of type {value: MouseEvent, timestamp: number}
* clickWithTimestamp.subscribe(data => {
* console.log(data);
* });
* ```
*
* @param scheduler
* @return {Observable<Timestamp<any>>|WebSocketSubject<T>|Observable<T>}
* @method timestamp
Expand Down