defer.js 591 B

12345678910111213141516171819
  1. /** PURE_IMPORTS_START _Observable,_from,_empty PURE_IMPORTS_END */
  2. import { Observable } from '../Observable';
  3. import { from } from './from';
  4. import { empty } from './empty';
  5. export function defer(observableFactory) {
  6. return new Observable(function (subscriber) {
  7. var input;
  8. try {
  9. input = observableFactory();
  10. }
  11. catch (err) {
  12. subscriber.error(err);
  13. return undefined;
  14. }
  15. var source = input ? from(input) : empty();
  16. return source.subscribe(subscriber);
  17. });
  18. }
  19. //# sourceMappingURL=defer.js.map