Front end of the Slack clone application.

sample.d.ts 1.5KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Observable } from '../Observable';
  2. /**
  3. * Emits the most recently emitted value from the source Observable whenever
  4. * another Observable, the `notifier`, emits.
  5. *
  6. * <span class="informal">It's like {@link sampleTime}, but samples whenever
  7. * the `notifier` Observable emits something.</span>
  8. *
  9. * <img src="./img/sample.png" width="100%">
  10. *
  11. * Whenever the `notifier` Observable emits a value or completes, `sample`
  12. * looks at the source Observable and emits whichever value it has most recently
  13. * emitted since the previous sampling, unless the source has not emitted
  14. * anything since the previous sampling. The `notifier` is subscribed to as soon
  15. * as the output Observable is subscribed.
  16. *
  17. * @example <caption>On every click, sample the most recent "seconds" timer</caption>
  18. * var seconds = Rx.Observable.interval(1000);
  19. * var clicks = Rx.Observable.fromEvent(document, 'click');
  20. * var result = seconds.sample(clicks);
  21. * result.subscribe(x => console.log(x));
  22. *
  23. * @see {@link audit}
  24. * @see {@link debounce}
  25. * @see {@link sampleTime}
  26. * @see {@link throttle}
  27. *
  28. * @param {Observable<any>} notifier The Observable to use for sampling the
  29. * source Observable.
  30. * @return {Observable<T>} An Observable that emits the results of sampling the
  31. * values emitted by the source Observable whenever the notifier Observable
  32. * emits value or completes.
  33. * @method sample
  34. * @owner Observable
  35. */
  36. export declare function sample<T>(this: Observable<T>, notifier: Observable<any>): Observable<T>;