Debian Codegraph @

src/main/java/io/reactivex/rxjava3/internal/jdk8/SingleFlattenStreamAsObservable.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 io.reactivex.rxjava3.annotations.NonNull;
19 import io.reactivex.rxjava3.core.*;
20 import io.reactivex.rxjava3.functions.Function;
21 import io.reactivex.rxjava3.internal.jdk8.MaybeFlattenStreamAsObservable.FlattenStreamMultiObserver;
22
23 /**
24 * Map the success value into a Java {@link Stream} and emits its values.
25 *
26 * @param <T> the source value type
27 * @param <R> the output value type
28 * @since 3.0.0
29 */
30 public final class SingleFlattenStreamAsObservable<T, R> extends Observable<R> {
31
32 final Single<T> source;
33
34 final Function<? super T, ? extends Stream<? extends R>> mapper;
35
36 public SingleFlattenStreamAsObservable(Single<T> source, Function<? super T, ? extends Stream<? extends R>> mapper) {
37 this.source = source;
38 this.mapper = mapper;
39 }
40
41 @Override
42 protected void subscribeActual(@NonNull Observer<? super R> s) {
43 source.subscribe(new FlattenStreamMultiObserver<>(s, mapper));
44 }
45 }