io.smallrye.mutiny.converters.multi.FromMaybe Maven / Gradle / Ivy
package io.smallrye.mutiny.converters.multi;
import io.reactivex.Maybe;
import io.reactivex.disposables.Disposable;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.converters.MultiConverter;
public class FromMaybe implements MultiConverter, T> {
public static final FromMaybe INSTANCE = new FromMaybe();
private FromMaybe() {
// Avoid direct instantiation
}
@Override
public Multi from(Maybe instance) {
return Multi.createFrom().emitter(sink -> {
Disposable disposable = instance.subscribe(
item -> {
sink.emit(item);
sink.complete();
},
sink::fail,
sink::complete);
sink.onTermination(() -> {
if (!disposable.isDisposed()) {
disposable.dispose();
}
});
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy