Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

timestamp.d.ts 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { OperatorFunction, SchedulerLike, Timestamp as TimestampInterface } from '../types';
  2. /**
  3. * Attaches a timestamp to each item emitted by an observable indicating when it was emitted
  4. *
  5. * The `timestamp` operator maps the *source* observable stream to an object of type
  6. * `{value: T, timestamp: R}`. The properties are generically typed. The `value` property contains the value
  7. * and type of the *source* observable. The `timestamp` is generated by the schedulers `now` function. By
  8. * default it uses the *async* scheduler which simply returns `Date.now()` (milliseconds since 1970/01/01
  9. * 00:00:00:000) and therefore is of type `number`.
  10. *
  11. * ![](timestamp.png)
  12. *
  13. * ## Example
  14. *
  15. * In this example there is a timestamp attached to the documents click event.
  16. *
  17. * ```ts
  18. * import { fromEvent } from 'rxjs';
  19. * import { timestamp } from 'rxjs/operators';
  20. *
  21. * const clickWithTimestamp = fromEvent(document, 'click').pipe(
  22. * timestamp()
  23. * );
  24. *
  25. * // Emits data of type {value: MouseEvent, timestamp: number}
  26. * clickWithTimestamp.subscribe(data => {
  27. * console.log(data);
  28. * });
  29. * ```
  30. *
  31. * @param scheduler
  32. * @return {Observable<Timestamp<any>>|WebSocketSubject<T>|Observable<T>}
  33. * @method timestamp
  34. * @owner Observable
  35. */
  36. export declare function timestamp<T>(scheduler?: SchedulerLike): OperatorFunction<T, Timestamp<T>>;
  37. export declare class Timestamp<T> implements TimestampInterface<T> {
  38. value: T;
  39. timestamp: number;
  40. constructor(value: T, timestamp: number);
  41. }