Package org.reactfx

Interface Suspendable

    • Method Detail

      • suspend

        Guard suspend()
        Suspends this suspendable object.

        In case of suspendable Observable, suspends notification delivery for this observable object. Notifications produced while suspended may be queued for later delivery, accumulated into a single cumulative notification, or discarded completely, depending on the concrete implementation.

        Returns:
        a Guard instance that can be released to end suspension. In case of suspended notifications, releasing the returned Guard will trigger delivery of queued or accumulated notifications, if any.

        The returned Guard is AutoCloseable, which makes it convenient to use in try-with-resources.

      • suspendWhile

        default void suspendWhile​(java.lang.Runnable r)
        Runs the given computation while suspended.

        Equivalent to

         try(Guard g = suspend()) {
             r.run();
         }
         
      • suspendWhile

        default <U> U suspendWhile​(java.util.function.Supplier<U> f)
        Runs the given computation while suspended. The code
         T t = this.suspendWhile(f);
         
        is equivalent to
         T t;
         try(Guard g = suspend()) {
             t = f.get();
         }
         
        Returns:
        the result produced by the given supplier f.
      • suspendWhen

        default Subscription suspendWhen​(javafx.beans.value.ObservableValue<java.lang.Boolean> condition)
        Arranges to suspend this Suspendable whenever condition is true.
        Returns:
        A Subscription that can be used to stop observing condition and stop suspending this Suspendable based on condition. If at the time of unsubscribing the returned Subscription this Suspendable was suspended due to condition being true, it will be resumed.