@@ -611,6 +611,19 @@ static <T> Streamable<List<T>> zip(Iterable<? extends Streamable<? extends T>> s
611611 // Operators
612612 // oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
613613
614+ /**
615+ * Blocks the current thread until this {@code Streamable} produces one item, which is then returned
616+ * @return the first item of this {@code Streamable}
617+ * @throws NoSuchElementException if the this {@code Streamable} is empty
618+ * @throws CancellationException if this {@code Streamable} failed with a checked exception
619+ * @throws RuntimeException if this {@code Streamable} failed with an unchecked exception
620+ */
621+ @ CheckReturnValue
622+ @ NonNull
623+ default T blockingFirst () {
624+ return StreamableBlocking .blockingFirst (this );
625+ }
626+
614627 /**
615628 * Collects all upstream values via the use of a {@link Collector} configuration
616629 * and emits its resulting value as a single item of the returned {@code Streamable}.
@@ -732,6 +745,33 @@ default Streamable<T> intercept(StreamableInterceptConfig<T> config) {
732745 config .onStream (), config .onNext (), config .onCurrent (), config .onFinish ()));
733746 }
734747
748+ /**
749+ * Signals the last item from the upstream {@code Streamable} or
750+ * the provided {@code defaultItem} if the upstream is empty, as a
751+ * {@link Single} instance.
752+ * @param defaultItem the item to signal if the upstream turns out to be empty
753+ * @return the new {@code Single} instance
754+ * @throws NullPointerException if {@code defaultItem} is {@code null}
755+ */
756+ @ CheckReturnValue
757+ @ NonNull
758+ default Single <T > last (@ NonNull T defaultItem ) {
759+ Objects .requireNonNull (defaultItem , "defaultItem is null" );
760+ return RxJavaPlugins .onAssembly (new StreamableLastAsSingle <>(this , defaultItem ));
761+ }
762+
763+ /**
764+ * Signals the last item from the upstream {@code Streamable} or a
765+ * {@link NoSuchElementException} if the upstream is empty, as a
766+ * {@link Single} instance.
767+ * @return the new {@code Single} instance
768+ */
769+ @ CheckReturnValue
770+ @ NonNull
771+ default Single <T > lastOrError () {
772+ return RxJavaPlugins .onAssembly (new StreamableLastAsSingle <>(this , null ));
773+ }
774+
735775 /**
736776 * <strong>This method requires advanced knowledge about building operators, please consider
737777 * other standard composition methods first;</strong>
@@ -801,6 +841,21 @@ default Streamable<T> onErrorResumeNext(@NonNull Function<? super Throwable, ? e
801841 return RxJavaPlugins .onAssembly (new StreamableOnErrorResumeNext <>(this , fallbackMapper ));
802842 }
803843
844+ /**
845+ * Skips the first {@code count} items and relays the rest to the downstream.
846+ * @param count the number of items to skip
847+ * @return the new {@Streamable} instance
848+ * @throws IllegalArgumentException if {@code count} is negative
849+ */
850+ @ CheckReturnValue
851+ @ NonNull
852+ default Streamable <T > skip (long count ) {
853+ if (count < 0 ) {
854+ throw new IllegalArgumentException ("count >= 0 expected but it was " + count );
855+ }
856+ return RxJavaPlugins .onAssembly (new StreamableSkip <>(this , count ));
857+ }
858+
804859 /**
805860 * Takes at most the given number of items from the upstream and relays it to the downstream,
806861 * then cancels the rest of the sequence.
0 commit comments