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 TypeMethodDescriptionbooleanadd(io.reactivex.rxjava3.disposables.Disposable d) Deprecated.<T> voidbind(@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> voidbindBidirectional(@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.booleandelete(io.reactivex.rxjava3.disposables.Disposable d) Deprecated.Deleting disposables from the composite disposable should not be done manually.voiddispose()booleanbooleanisFresh()Returns true if the disposable is not disposed and clean.voidlisten(@NotNull PropertyChangeSupport support, @NotNull PropertyChangeListener changeListener) Adds a beans property change listener to a property change support and removes it on destroy.voidlisten(@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> voidlisten(@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.booleanrefresh()Refreshes the disposable if it is disposed.booleanremove(io.reactivex.rxjava3.disposables.Disposable d) Deprecated.Removing disposables from the composite disposable should not be done manually.voidsubscribe(@NotNull io.reactivex.rxjava3.core.Completable completable) Subscribes to and observes a completable on the FX thread.voidsubscribe(@NotNull io.reactivex.rxjava3.core.Completable completable, @NotNull io.reactivex.rxjava3.functions.Action onComplete) Subscribes to and observes a completable on the FX thread.voidsubscribe(@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> voidsubscribe(@NotNull io.reactivex.rxjava3.core.Observable<@NotNull T> observable) Subscribes to and observes an observable on the FX thread.<T> voidsubscribe(@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> voidsubscribe(@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> voidsubscribe(@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.voidsubscribe(@NotNull io.reactivex.rxjava3.disposables.Disposable disposable) Adds a disposable to be disposed when the controller is destroyed.voidAdds 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:
isDisposedin interfaceio.reactivex.rxjava3.disposables.Disposable
-
dispose
public void dispose()- Specified by:
disposein interfaceio.reactivex.rxjava3.disposables.Disposable
-
refresh
public boolean refresh()Description copied from interface:RefreshableDisposableRefreshes the disposable if it is disposed. If the disposable is not disposed (or not initialized), this method does nothing.- Specified by:
refreshin interfaceRefreshableDisposable- Returns:
- true if the disposable can now be reused, false otherwise
-
isFresh
public boolean isFresh()Description copied from interface:RefreshableDisposableReturns true if the disposable is not disposed and clean.- Specified by:
isFreshin 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:
addin 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:
removein 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:
deletein interfaceio.reactivex.rxjava3.disposables.DisposableContainer- Parameters:
d- The disposable to add- Returns:
- true if the disposable was added, false otherwise
-
subscribe(Disposable)instead