Class Subscriber

java.lang.Object
org.fulib.fx.controller.Subscriber
All Implemented Interfaces:
io.reactivex.rxjava3.disposables.Disposable, io.reactivex.rxjava3.disposables.DisposableContainer, RefreshableDisposable, RefreshableDisposableContainer

public class Subscriber extends Object implements RefreshableDisposableContainer
A subscriber is used to subscribe to observables and listen to properties.

The subscriber saves all subscriptions and disposes them when it is destroyed. Subscribers which are declared with a field in a controller are automatically destroyed when the controller is destroyed.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new subscriber.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(io.reactivex.rxjava3.disposables.Disposable d)
    Deprecated.
    <T> void
    bind(@NotNull javafx.beans.property.Property<@NotNull T> property, @NotNull javafx.beans.value.ObservableValue<@NotNull T> other)
    Binds a property to another property (unidirectional) and unbinds it on destroy.
    <T> void
    bindBidirectional(@NotNull javafx.beans.property.Property<@NotNull T> property, @NotNull javafx.beans.property.Property<@NotNull T> other)
    Binds a property to another property (bidirectional) and unbinds it on destroy.
    boolean
    delete(io.reactivex.rxjava3.disposables.Disposable d)
    Deprecated.
    Deleting disposables from the composite disposable should not be done manually.
    void
     
    boolean
     
    boolean
    Returns true if the disposable is not disposed and clean.
    void
    listen(@NotNull PropertyChangeSupport support, @NotNull PropertyChangeListener changeListener)
    Adds a beans property change listener to a property change support and removes it on destroy.
    void
    listen(@NotNull PropertyChangeSupport support, @NotNull String property, @NotNull PropertyChangeListener changeListener)
    Adds a beans property change listener to a property change support and removes it on destroy.
    <T> void
    listen(@NotNull javafx.beans.value.ObservableValue<@NotNull T> property, @NotNull javafx.beans.value.ChangeListener<? super @NotNull T> listener)
    Adds a listener to a property and removes it on destroy.
    boolean
    Refreshes the disposable if it is disposed.
    boolean
    remove(io.reactivex.rxjava3.disposables.Disposable d)
    Deprecated.
    Removing disposables from the composite disposable should not be done manually.
    void
    subscribe(@NotNull io.reactivex.rxjava3.core.Completable completable)
    Subscribes to and observes a completable on the FX thread.
    void
    subscribe(@NotNull io.reactivex.rxjava3.core.Completable completable, @NotNull io.reactivex.rxjava3.functions.Action onComplete)
    Subscribes to and observes a completable on the FX thread.
    void
    subscribe(@NotNull io.reactivex.rxjava3.core.Completable completable, @NotNull io.reactivex.rxjava3.functions.Consumer<? super @NotNull Throwable> onError)
    Subscribes to and observes a completable on the FX thread.
    <T> void
    subscribe(@NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable)
    Subscribes to and observes an observable on the FX thread.
    <T> void
    subscribe(@NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable, @NotNull io.reactivex.rxjava3.core.Scheduler subscribeOn, @NotNull io.reactivex.rxjava3.functions.Consumer<@NotNull T> onNext, @NotNull io.reactivex.rxjava3.functions.Consumer<? super @NotNull Throwable> onError)
    Subscribes to an observable on a scheduler and observes it on the FX thread.
    <T> void
    subscribe(@NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable, @NotNull io.reactivex.rxjava3.functions.Consumer<@NotNull T> onNext)
    Subscribes to and observes an observable on the FX thread.
    <T> void
    subscribe(@NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable, @NotNull io.reactivex.rxjava3.functions.Consumer<@NotNull T> onNext, @NotNull io.reactivex.rxjava3.functions.Consumer<? super @NotNull Throwable> onError)
    Subscribes to and observes a completable on the FX thread.
    void
    subscribe(@NotNull io.reactivex.rxjava3.disposables.Disposable disposable)
    Adds a disposable to be disposed when the controller is destroyed.
    void
    subscribe(@NotNull Runnable action)
    Adds a runnable to be executed when the controller is destroyed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Subscriber

      @Inject public Subscriber()
      Creates a new subscriber.
  • Method Details

    • subscribe

      public void subscribe(@NotNull @NotNull Runnable action)
      Adds a runnable to be executed when the controller is destroyed.
      Parameters:
      action - the runnable to execute
    • subscribe

      public void subscribe(@NotNull @NotNull io.reactivex.rxjava3.disposables.Disposable disposable)
      Adds a disposable to be disposed when the controller is destroyed.
      Parameters:
      disposable - the disposable to dispose
    • subscribe

      public void subscribe(@NotNull @NotNull io.reactivex.rxjava3.core.Completable completable)
      Subscribes to and observes a completable on the FX thread.
      Parameters:
      completable - the completable to subscribe to
    • subscribe

      public void subscribe(@NotNull @NotNull io.reactivex.rxjava3.core.Completable completable, @NotNull @NotNull io.reactivex.rxjava3.functions.Action onComplete)
      Subscribes to and observes a completable on the FX thread.
      Parameters:
      completable - the completable to subscribe to
      onComplete - the consumer to call on each event
    • subscribe

      public void subscribe(@NotNull @NotNull io.reactivex.rxjava3.core.Completable completable, @NotNull @NotNull io.reactivex.rxjava3.functions.Consumer<? super @NotNull Throwable> onError)
      Subscribes to and observes a completable on the FX thread.
      Parameters:
      completable - the completable to subscribe to
      onError - the consumer to call on an error
    • subscribe

      public <T> void subscribe(@NotNull @NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable, @NotNull @NotNull io.reactivex.rxjava3.core.Scheduler subscribeOn, @NotNull @NotNull io.reactivex.rxjava3.functions.Consumer<@NotNull T> onNext, @NotNull @NotNull io.reactivex.rxjava3.functions.Consumer<? super @NotNull Throwable> onError)
      Subscribes to an observable on a scheduler and observes it on the FX thread.
      Type Parameters:
      T - the type of the items emitted by the Observable
      Parameters:
      observable - the observable to subscribe to
      onNext - the action to call on each event
      onError - the consumer to call on an error
      subscribeOn - the scheduler to subscribe on
    • subscribe

      public <T> void subscribe(@NotNull @NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable)
      Subscribes to and observes an observable on the FX thread.
      Type Parameters:
      T - the type of the items emitted by the Observable
      Parameters:
      observable - the observable to subscribe to
    • subscribe

      public <T> void subscribe(@NotNull @NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable, @NotNull @NotNull io.reactivex.rxjava3.functions.Consumer<@NotNull T> onNext)
      Subscribes to and observes an observable on the FX thread.
      Type Parameters:
      T - the type of the items emitted by the Observable
      Parameters:
      observable - the observable to subscribe to
      onNext - the action to call on completion
    • subscribe

      public <T> void subscribe(@NotNull @NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable, @NotNull @NotNull io.reactivex.rxjava3.functions.Consumer<@NotNull T> onNext, @NotNull @NotNull io.reactivex.rxjava3.functions.Consumer<? super @NotNull Throwable> onError)
      Subscribes to and observes a completable on the FX thread.
      Type Parameters:
      T - the type of the items emitted by the Observable
      Parameters:
      observable - the observable to subscribe to
      onNext - the consumer to call on each event
      onError - the consumer to call on an error
    • listen

      public <T> void listen(@NotNull @NotNull javafx.beans.value.ObservableValue<@NotNull T> property, @NotNull @NotNull javafx.beans.value.ChangeListener<? super @NotNull T> listener)
      Adds a listener to a property and removes it on destroy.
      Type Parameters:
      T - the type of the property value
      Parameters:
      property - the property or observable to listen to
      listener - the listener to add
    • listen

      public void listen(@NotNull @NotNull PropertyChangeSupport support, @NotNull @NotNull String property, @NotNull @NotNull PropertyChangeListener changeListener)
      Adds a beans property change listener to a property change support and removes it on destroy.
      Parameters:
      support - The property change support (e.g. a model)
      property - The property to listen to
      changeListener - The listener to add
    • listen

      public void listen(@NotNull @NotNull PropertyChangeSupport support, @NotNull @NotNull PropertyChangeListener changeListener)
      Adds a beans property change listener to a property change support and removes it on destroy.
      Parameters:
      support - The property change support (e.g. a model)
      changeListener - The listener to add
    • bind

      public <T> void bind(@NotNull @NotNull javafx.beans.property.Property<@NotNull T> property, @NotNull @NotNull javafx.beans.value.ObservableValue<@NotNull T> other)
      Binds a property to another property (unidirectional) and unbinds it on destroy.
      Type Parameters:
      T - The type of the property
      Parameters:
      property - The property to bind
      other - The property to bind to
    • bindBidirectional

      public <T> void bindBidirectional(@NotNull @NotNull javafx.beans.property.Property<@NotNull T> property, @NotNull @NotNull javafx.beans.property.Property<@NotNull T> other)
      Binds a property to another property (bidirectional) and unbinds it on destroy.
      Type Parameters:
      T - The type of the property
      Parameters:
      property - The property to bind
      other - The property to bind to
    • isDisposed

      public boolean isDisposed()
      Specified by:
      isDisposed in interface io.reactivex.rxjava3.disposables.Disposable
    • dispose

      public void dispose()
      Specified by:
      dispose in interface io.reactivex.rxjava3.disposables.Disposable
    • refresh

      public boolean refresh()
      Description copied from interface: RefreshableDisposable
      Refreshes the disposable if it is disposed. If the disposable is not disposed (or not initialized), this method does nothing.
      Specified by:
      refresh in interface RefreshableDisposable
      Returns:
      true if the disposable can now be reused, false otherwise
    • isFresh

      public boolean isFresh()
      Description copied from interface: RefreshableDisposable
      Returns true if the disposable is not disposed and clean.
      Specified by:
      isFresh in interface RefreshableDisposable
      Returns:
      true if the disposable is not disposed and clean, false otherwise
    • add

      @Deprecated public boolean add(io.reactivex.rxjava3.disposables.Disposable d)
      Deprecated.
      Adds a disposable to the composite disposable.
      Specified by:
      add in interface io.reactivex.rxjava3.disposables.DisposableContainer
      Parameters:
      d - The disposable to add
      Returns:
      true if the disposable was added, false otherwise
    • remove

      @Deprecated public boolean remove(io.reactivex.rxjava3.disposables.Disposable d)
      Deprecated.
      Removing disposables from the composite disposable should not be done manually.
      Adds a disposable to the composite disposable.
      Specified by:
      remove in interface io.reactivex.rxjava3.disposables.DisposableContainer
      Parameters:
      d - The disposable to add
      Returns:
      true if the disposable was added, false otherwise
    • delete

      @Deprecated public boolean delete(io.reactivex.rxjava3.disposables.Disposable d)
      Deprecated.
      Deleting disposables from the composite disposable should not be done manually.
      Adds a disposable to the composite disposable.
      Specified by:
      delete in interface io.reactivex.rxjava3.disposables.DisposableContainer
      Parameters:
      d - The disposable to add
      Returns:
      true if the disposable was added, false otherwise