Debian Codegraph @

src/main/java/io/reactivex/rxjava3/internal/jdk8/SingleFlattenStreamAsFlowable.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.internal.jdk8;
15
16 import java.util.stream.Stream;
17
18 import org.reactivestreams.Subscriber;
19
20 import io.reactivex.rxjava3.annotations.NonNull;
21 import io.reactivex.rxjava3.core.*;
22 import io.reactivex.rxjava3.functions.Function;
23 import io.reactivex.rxjava3.internal.jdk8.MaybeFlattenStreamAsFlowable.FlattenStreamMultiObserver;
24
25 /**
26 * Map the success value into a Java {@link Stream} and emits its values.
27 *
28 * @param <T> the source value type
29 * @param <R> the output value type
30 * @since 3.0.0
31 */
32 public final class SingleFlattenStreamAsFlowable<T, R> extends Flowable<R> {
33
34 final Single<T> source;
35
36 final Function<? super T, ? extends Stream<? extends R>> mapper;
37
38 public SingleFlattenStreamAsFlowable(Single<T> source, Function<? super T, ? extends Stream<? extends R>> mapper) {
39 this.source = source;
40 this.mapper = mapper;
41 }
42
43 @Override
44 protected void subscribeActual(@NonNull Subscriber<? super R> s) {
45 source.subscribe(new FlattenStreamMultiObserver<>(s, mapper));
46 }
47 }