a zip code crypto-currency system good for red ONLY

windowWhen.d.ts 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Observable } from '../Observable';
  2. /**
  3. * Branch out the source Observable values as a nested Observable using a
  4. * factory function of closing Observables to determine when to start a new
  5. * window.
  6. *
  7. * <span class="informal">It's like {@link bufferWhen}, but emits a nested
  8. * Observable instead of an array.</span>
  9. *
  10. * <img src="./img/windowWhen.png" width="100%">
  11. *
  12. * Returns an Observable that emits windows of items it collects from the source
  13. * Observable. The output Observable emits connected, non-overlapping windows.
  14. * It emits the current window and opens a new one whenever the Observable
  15. * produced by the specified `closingSelector` function emits an item. The first
  16. * window is opened immediately when subscribing to the output Observable.
  17. *
  18. * @example <caption>Emit only the first two clicks events in every window of [1-5] random seconds</caption>
  19. * var clicks = Rx.Observable.fromEvent(document, 'click');
  20. * var result = clicks
  21. * .windowWhen(() => Rx.Observable.interval(1000 + Math.random() * 4000))
  22. * .map(win => win.take(2)) // each window has at most 2 emissions
  23. * .mergeAll(); // flatten the Observable-of-Observables
  24. * result.subscribe(x => console.log(x));
  25. *
  26. * @see {@link window}
  27. * @see {@link windowCount}
  28. * @see {@link windowTime}
  29. * @see {@link windowToggle}
  30. * @see {@link bufferWhen}
  31. *
  32. * @param {function(): Observable} closingSelector A function that takes no
  33. * arguments and returns an Observable that signals (on either `next` or
  34. * `complete`) when to close the previous window and start a new one.
  35. * @return {Observable<Observable<T>>} An observable of windows, which in turn
  36. * are Observables.
  37. * @method windowWhen
  38. * @owner Observable
  39. */
  40. export declare function windowWhen<T>(this: Observable<T>, closingSelector: () => Observable<any>): Observable<Observable<T>>;