🚥 Queue Observable
Available Since 0.0.50
QueueObservable is an interface that extends CollectionObservable and adds the standard java.util.Queue operations to any observable collection whose backing store is a Queue. It lets you work with a queue in the reactive style: every mutation automatically flags downstream observables as dirty.
Interface Definition
Implementations
Class | Backing collection |
|---|---|
|
|
See LinkedList Observable for the concrete implementation.
Method Reference
Inserting elements
Method | Description | Notifies observers |
|---|---|---|
| Adds element; returns | Yes |
| Offers element; returns | Yes (on success) |
Both methods append to the tail of the queue for a LinkedList-backed implementation.
Retrieving and removing the head
Method | Queue empty → | Notifies observers |
|---|---|---|
| Returns | Yes (when non-empty) |
| Throws | Yes (when non-empty) |
Use poll() for a null-safe removal and remove() when you expect the queue to be non-empty and want a hard failure if it is not.
Inspecting the head (non-mutating)
Method | Queue empty → | Notifies observers |
|---|---|---|
| Returns | Never |
| Throws | Never |
peek() and element() are purely read-only — calling them will never flag observers as dirty.
FIFO Queue Pattern
QueueObservable is ideal for modelling first-in-first-out pipelines whose size (or head element) other parts of your application need to observe reactively:
Observer Notification Rules
A quick summary of which operations trigger observer notifications:
Operation | Triggers notification |
|---|---|
| Yes |
| Yes |
| No |
| No |
| Yes |
| No |
| Yes |
| No |