improve takeUntil and takeWhile to have overload to includeLastValue = true

Feature Request

takeUntil and takeWhile does not include last value.

Please see this post, there are links in the comments to other users having similar problems.
https://stackoverflow.com/questions/51767204/rxjs-interval-with-takeuntil-to-publish-last-value

Describe the solution you’d like
Need option to get last value of takeUntil and takeWhile

Describe alternatives you’ve considered
Workaround is in stack overflow post but is not clean.

1 possible answer(s) on “improve takeUntil and takeWhile to have overload to includeLastValue = true

  1. Given that I have people inside of Google making a custom operator to suit this need, I think it’s time to discuss implementing it.

    Proposal

    Add a second argument boolean inclusive, that will include the first value to return false for takeWhile.

    source$.pipe(takeWhile(predicate, true)); // inclusive of last value

    Workaround

    Until then, there are super-gross workarounds that use current operators like:

    const takeWhileInclusive = (predicate) => (source) =>
      source.pipe(
        concatMap((value, i) => prediciate(value, i) ? of({ value }) : of({ value }, { kill: true })),
        takeWhile(({ kill }) => !kill),
        map(({ value }) => value),
      );
    
    // usage
    
    source$.pipe(takeWhileInclusive(predicate));