@@ -142,6 +142,43 @@ class Mono[T] private(private val jMono: JMono[T]) extends Publisher[T] with Map
142142 */
143143 final def block (timeout : Duration ): T = jMono.block(timeout)
144144
145+ /**
146+ * Subscribe to this {[[Mono ]] Mono} and <strong>block indefinitely</strong> until a next signal is
147+ * received or the Mono completes empty. Returns an [[Option ]], which can be used
148+ * to replace the empty case with an Exception via [[Option.orElse(throw exception) ]].
149+ * In case the Mono itself errors, the original exception is thrown (wrapped in a
150+ * [[RuntimeException ]] if it was a checked exception).
151+ *
152+ * <p>
153+ * <img class="marble" src="https://raw.githubusercontent.com/reactor/reactor-core/v3.1.1.RELEASE/src/docs/marble/block.png" alt="">
154+ * <p>
155+ * Note that each blockOptional() will trigger a new subscription: in other words, the result
156+ * might miss signal from hot publishers.
157+ *
158+ * @return T the result
159+ */
160+ final def blockOption (): Option [T ] = jMono.blockOptional()
161+
162+ /**
163+ * Subscribe to this [[Mono ]] and <strong>block</strong> until a next signal is
164+ * received, the Mono completes empty or a timeout expires. Returns an [[Option ]]
165+ * for the first two cases, which can be used to replace the empty case with an
166+ * Exception via [[Option.orElse(throw exception) ]].
167+ * In case the Mono itself errors, the original exception is thrown (wrapped in a
168+ * [[RuntimeException ]] if it was a checked exception).
169+ * If the provided timeout expires, a [[RuntimeException ]] is thrown.
170+ *
171+ * <p>
172+ * <img class="marble" src="https://raw.githubusercontent.com/reactor/reactor-core/v3.1.1.RELEASE/src/docs/marble/block.png" alt="">
173+ * <p>
174+ * Note that each block() will trigger a new subscription: in other words, the result
175+ * might miss signal from hot publishers.
176+ *
177+ * @param timeout maximum time period to wait for before raising a [[RuntimeException ]]
178+ * @return T the result
179+ */
180+ final def blockOption (timeout : Duration ): Option [T ] = jMono.blockOptional(timeout)
181+
145182 /**
146183 * Cast the current [[Mono ]] produced type into a target produced type.
147184 *
0 commit comments