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 TypeMethodDescriptionvoidAdds an item to the list of items to dispose.voiddispose()booleanbooleanisFresh()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.booleanrefresh()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:
disposein interfaceio.reactivex.rxjava3.disposables.Disposable
-
isDisposed
public boolean isDisposed()- Specified by:
isDisposedin 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
Adds an item to the list of items to dispose.- Parameters:
item- the item to dispose
-