/** * Extact one value from the selected pipe or an zero Maybe if it doesn't exist. Currently only Adapter's and not Publishers * are managed by Pipes so Publisher errors are not propagated (@see {@link Pipes#oneValue(Object)} or @see {@link Pipes#oneOrError(Object)} is better at the moment. * * <pre> * {@code * Queue<String> q = new Queue<>(); pipes.register("hello", q); pipes.push("hello", "world"); pipes.push("hello", "world2"); pipes.oneValueOrError("hello").getValue(); //Try["world"] * } * </pre> * * @param key : Adapter identifier * @return */ @Deprecated //errors aren't propagated across Adapters (at least without continuations) public Option<Try<V, Throwable>> oneValueOrError(final K key) { final ValueSubscriber<V> sub = ValueSubscriber.subscriber(); return get(key).peek(a -> a.stream() .subscribe(sub)) .map(a -> sub.toTry(Throwable.class)); }
/** * Extact one value from the selected pipe or an zero Maybe if it doesn't exist. Currently only Adapter's and not Publishers * are managed by Pipes so Publisher errors are not propagated (@see {@link Pipes#oneValue(Object)} or @see {@link Pipes#oneOrError(Object)} is better at the moment. * * <pre> * {@code * Queue<String> q = new Queue<>(); pipes.register("hello", q); pipes.push("hello", "world"); pipes.push("hello", "world2"); pipes.oneValueOrError("hello",Throwable.class).getValue(); //Try["world"] * } * </pre> * * @param key * @param classes * @return */ @Deprecated //errors aren't propagated across Adapters (at least without continuations) public <X extends Throwable> Option<Try<V, X>> oneValueOrError(final K key, final Class<X>... classes) { final ValueSubscriber<V> sub = ValueSubscriber.subscriber(); return get(key).peek(a -> a.stream() .subscribe(sub)) .map(a -> sub.toTry(classes)); }