a zip code crypto-currency system good for red ONLY

finalize.js 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. import { Subscriber } from '../Subscriber';
  2. import { Subscription } from '../Subscription';
  3. /**
  4. * Returns an Observable that mirrors the source Observable, but will call a specified function when
  5. * the source terminates on complete or error.
  6. * @param {function} callback Function to be called when source terminates.
  7. * @return {Observable} An Observable that mirrors the source, but will call the specified function on termination.
  8. * @method finally
  9. * @owner Observable
  10. */
  11. export function finalize(callback) {
  12. return (source) => source.lift(new FinallyOperator(callback));
  13. }
  14. class FinallyOperator {
  15. constructor(callback) {
  16. this.callback = callback;
  17. }
  18. call(subscriber, source) {
  19. return source.subscribe(new FinallySubscriber(subscriber, this.callback));
  20. }
  21. }
  22. /**
  23. * We need this JSDoc comment for affecting ESDoc.
  24. * @ignore
  25. * @extends {Ignored}
  26. */
  27. class FinallySubscriber extends Subscriber {
  28. constructor(destination, callback) {
  29. super(destination);
  30. this.add(new Subscription(callback));
  31. }
  32. }
  33. //# sourceMappingURL=finalize.js.map