defer.js 646 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Observable_1 = require("../Observable");
  4. var from_1 = require("./from");
  5. var empty_1 = require("./empty");
  6. function defer(observableFactory) {
  7. return new Observable_1.Observable(function (subscriber) {
  8. var input;
  9. try {
  10. input = observableFactory();
  11. }
  12. catch (err) {
  13. subscriber.error(err);
  14. return undefined;
  15. }
  16. var source = input ? from_1.from(input) : empty_1.empty();
  17. return source.subscribe(subscriber);
  18. });
  19. }
  20. exports.defer = defer;
  21. //# sourceMappingURL=defer.js.map