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

multicast.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var ConnectableObservable_1 = require("../observable/ConnectableObservable");
  4. function multicast(subjectOrSubjectFactory, selector) {
  5. return function multicastOperatorFunction(source) {
  6. var subjectFactory;
  7. if (typeof subjectOrSubjectFactory === 'function') {
  8. subjectFactory = subjectOrSubjectFactory;
  9. }
  10. else {
  11. subjectFactory = function subjectFactory() {
  12. return subjectOrSubjectFactory;
  13. };
  14. }
  15. if (typeof selector === 'function') {
  16. return source.lift(new MulticastOperator(subjectFactory, selector));
  17. }
  18. var connectable = Object.create(source, ConnectableObservable_1.connectableObservableDescriptor);
  19. connectable.source = source;
  20. connectable.subjectFactory = subjectFactory;
  21. return connectable;
  22. };
  23. }
  24. exports.multicast = multicast;
  25. var MulticastOperator = (function () {
  26. function MulticastOperator(subjectFactory, selector) {
  27. this.subjectFactory = subjectFactory;
  28. this.selector = selector;
  29. }
  30. MulticastOperator.prototype.call = function (subscriber, source) {
  31. var selector = this.selector;
  32. var subject = this.subjectFactory();
  33. var subscription = selector(subject).subscribe(subscriber);
  34. subscription.add(source.subscribe(subject));
  35. return subscription;
  36. };
  37. return MulticastOperator;
  38. }());
  39. exports.MulticastOperator = MulticastOperator;
  40. //# sourceMappingURL=multicast.js.map