a zip code crypto-currency system good for red ONLY

do.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { tap as higherOrder } from '../operators/tap';
  2. /* tslint:enable:max-line-length */
  3. /**
  4. * Perform a side effect for every emission on the source Observable, but return
  5. * an Observable that is identical to the source.
  6. *
  7. * <span class="informal">Intercepts each emission on the source and runs a
  8. * function, but returns an output which is identical to the source as long as errors don't occur.</span>
  9. *
  10. * <img src="./img/do.png" width="100%">
  11. *
  12. * Returns a mirrored Observable of the source Observable, but modified so that
  13. * the provided Observer is called to perform a side effect for every value,
  14. * error, and completion emitted by the source. Any errors that are thrown in
  15. * the aforementioned Observer or handlers are safely sent down the error path
  16. * of the output Observable.
  17. *
  18. * This operator is useful for debugging your Observables for the correct values
  19. * or performing other side effects.
  20. *
  21. * Note: this is different to a `subscribe` on the Observable. If the Observable
  22. * returned by `do` is not subscribed, the side effects specified by the
  23. * Observer will never happen. `do` therefore simply spies on existing
  24. * execution, it does not trigger an execution to happen like `subscribe` does.
  25. *
  26. * @example <caption>Map every click to the clientX position of that click, while also logging the click event</caption>
  27. * var clicks = Rx.Observable.fromEvent(document, 'click');
  28. * var positions = clicks
  29. * .do(ev => console.log(ev))
  30. * .map(ev => ev.clientX);
  31. * positions.subscribe(x => console.log(x));
  32. *
  33. * @see {@link map}
  34. * @see {@link subscribe}
  35. *
  36. * @param {Observer|function} [nextOrObserver] A normal Observer object or a
  37. * callback for `next`.
  38. * @param {function} [error] Callback for errors in the source.
  39. * @param {function} [complete] Callback for the completion of the source.
  40. * @return {Observable} An Observable identical to the source, but runs the
  41. * specified Observer or callback(s) for each item.
  42. * @method do
  43. * @name do
  44. * @owner Observable
  45. */
  46. export function _do(nextOrObserver, error, complete) {
  47. return higherOrder(nextOrObserver, error, complete)(this);
  48. }
  49. //# sourceMappingURL=do.js.map