Package org.fulib.fx.data.disposable
Class ItemListDisposable<T>
java.lang.Object
org.fulib.fx.data.disposable.ItemListDisposable<T>
- Type Parameters:
T
- the type of the items
- All Implemented Interfaces:
io.reactivex.rxjava3.disposables.Disposable
,RefreshableDisposable
A disposable which disposes a list of items when it is disposed.
The items are disposed in reverse order, so the last item is disposed first (LIFO).
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an item to the list of items to dispose.void
dispose()
boolean
boolean
isFresh()
Returns true if the disposable is not disposed and clean.static <T> ItemListDisposable<T>
Creates a new disposable which disposes all items in the list with the given action when it is disposed.static <T> ItemListDisposable<T>
Creates a new disposable which disposes all items in the list with the given action when it is disposed.boolean
refresh()
Refreshes the disposable if it is disposed.
-
Method Details
-
of
Creates a new disposable which disposes all items in the list with the given action when it is disposed.- Type Parameters:
T
- the type of the items- Parameters:
onDispose
- the action to execute for an item when the disposable is disposedtoDispose
- the items to dispose- Returns:
- the disposable
-
of
Creates a new disposable which disposes all items in the list with the given action when it is disposed.- Type Parameters:
T
- the type of the items- Parameters:
onDispose
- the action to execute for an item when the disposable is disposedtoDispose
- the items to dispose- Returns:
- the disposable
-
dispose
public void dispose()- Specified by:
dispose
in interfaceio.reactivex.rxjava3.disposables.Disposable
-
isDisposed
public boolean isDisposed()- Specified by:
isDisposed
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
Adds an item to the list of items to dispose.- Parameters:
item
- the item to dispose
-