toSubscriber.js 760 B

1234567891011121314151617181920
  1. "use strict";
  2. var Subscriber_1 = require('../Subscriber');
  3. var rxSubscriber_1 = require('../symbol/rxSubscriber');
  4. var Observer_1 = require('../Observer');
  5. function toSubscriber(nextOrObserver, error, complete) {
  6. if (nextOrObserver) {
  7. if (nextOrObserver instanceof Subscriber_1.Subscriber) {
  8. return nextOrObserver;
  9. }
  10. if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
  11. return nextOrObserver[rxSubscriber_1.rxSubscriber]();
  12. }
  13. }
  14. if (!nextOrObserver && !error && !complete) {
  15. return new Subscriber_1.Subscriber(Observer_1.empty);
  16. }
  17. return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
  18. }
  19. exports.toSubscriber = toSubscriber;
  20. //# sourceMappingURL=toSubscriber.js.map