delayWhen.js 646 B

12345678910111213
  1. import { concat } from '../observable/concat';
  2. import { take } from './take';
  3. import { ignoreElements } from './ignoreElements';
  4. import { mapTo } from './mapTo';
  5. import { mergeMap } from './mergeMap';
  6. import { innerFrom } from '../observable/innerFrom';
  7. export function delayWhen(delayDurationSelector, subscriptionDelay) {
  8. if (subscriptionDelay) {
  9. return (source) => concat(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
  10. }
  11. return mergeMap((value, index) => innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value)));
  12. }
  13. //# sourceMappingURL=delayWhen.js.map