Package org.fulib.fx.controller
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
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 -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
dispose()
boolean
boolean
isFresh()
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
refresh()
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
Adds a runnable to be executed when the controller is destroyed.
-
Constructor Details
-
Subscriber
@Inject public Subscriber()Creates a new subscriber.
-
-
Method Details
-
subscribe
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 toonComplete
- 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 toonError
- 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 toonNext
- the action to call on each eventonError
- the consumer to call on an errorsubscribeOn
- 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 toonNext
- 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 toonNext
- the consumer to call on each eventonError
- 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 tolistener
- 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 tochangeListener
- 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 bindother
- 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 bindother
- The property to bind to
-
isDisposed
public boolean isDisposed()- Specified by:
isDisposed
in interfaceio.reactivex.rxjava3.disposables.Disposable
-
dispose
public void dispose()- Specified by:
dispose
in interfaceio.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 interfaceRefreshableDisposable
- 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 interfaceRefreshableDisposable
- Returns:
- true if the disposable is not disposed and clean, false otherwise
-
add
Deprecated.Usesubscribe(Disposable)
insteadAdds a disposable to the composite disposable.- Specified by:
add
in interfaceio.reactivex.rxjava3.disposables.DisposableContainer
- Parameters:
d
- The disposable to add- Returns:
- true if the disposable was added, false otherwise
-
remove
Deprecated.Removing disposables from the composite disposable should not be done manually.Adds a disposable to the composite disposable.- Specified by:
remove
in interfaceio.reactivex.rxjava3.disposables.DisposableContainer
- Parameters:
d
- The disposable to add- Returns:
- true if the disposable was added, false otherwise
-
delete
Deprecated.Deleting disposables from the composite disposable should not be done manually.Adds a disposable to the composite disposable.- Specified by:
delete
in interfaceio.reactivex.rxjava3.disposables.DisposableContainer
- Parameters:
d
- The disposable to add- Returns:
- true if the disposable was added, false otherwise
-
subscribe(Disposable)
instead