using.js 580 B

1234567891011121314151617
  1. import { Observable } from '../Observable';
  2. import { innerFrom } from './innerFrom';
  3. import { EMPTY } from './empty';
  4. export function using(resourceFactory, observableFactory) {
  5. return new Observable(function (subscriber) {
  6. var resource = resourceFactory();
  7. var result = observableFactory(resource);
  8. var source = result ? innerFrom(result) : EMPTY;
  9. source.subscribe(subscriber);
  10. return function () {
  11. if (resource) {
  12. resource.unsubscribe();
  13. }
  14. };
  15. });
  16. }
  17. //# sourceMappingURL=using.js.map