code: public static <E> CompletableSource resolveScopeFromLifecycle(
        final LifecycleScopeProvider<E> provider, final boolean checkEndBoundary)
        throws OutsideScopeException {
      E lastEvent = provider.peekLifecycle();
      CorrespondingEventsFunction<E> eventsFunction = provider.correspondingEvents();
      if (lastEvent == null) {
        throw new LifecycleNotStartedException();
      }
      E endEvent;
      try {
        endEvent = eventsFunction.apply(lastEvent);
      } catch (Exception e) {
        if (checkEndBoundary && e instanceof LifecycleEndedException) {
          Consumer<? super OutsideScopeException> handler =
              AutoDisposePlugins.getOutsideScopeHandler();
          if (handler != null) {
            try {
              handler.accept((LifecycleEndedException) e);
  
              // Swallowed the end exception, just silently dispose immediately.
              return Completable.complete();
            } catch (Exception e1) {
              return Completable.error(e1);
            }
          }
          throw e;
        }
        return Completable.error(e);
      }
      return resolveScopeFromLifecycle(provider.lifecycle(), endEvent);
    }
docs: Overload for resolving lifecycle providers allows configuration of checking "end" boundaries of
  lifecycles. That is, they will ensure that the lifecycle has both started and not ended, and
  otherwise will throw one of {@link LifecycleNotStartedException} (if {@link
  LifecycleScopeProvider#peekLifecycle() peekLifecycle} returns {@code null}) or {@link
  LifecycleEndedException} if the lifecycle is ended. To configure the runtime behavior of these
  exceptions, see {@link AutoDisposePlugins}.
  
  <p><em>Note:</em> This resolves the scope immediately, so consider deferring execution as
  needed, such as using {@link Completable#defer(Callable) defer}.
  
  @param provider the {@link LifecycleScopeProvider} to resolve.
  @param checkEndBoundary whether or not to check that the lifecycle has ended
  @param <E> the lifecycle event type
  @return a resolved {@link CompletableSource} representation of a given provider
  @throws OutsideScopeException if the {@link LifecycleScopeProvider#correspondingEvents()}
  throws an {@link OutsideScopeException} during resolution.