Creates a time- and size-bounded replay subject.
In this setting, the
ReplaySubject internally tags each received item with a timestamp value
supplied by the
Scheduler and holds at most
size items in its internal buffer. It evicts
items from the start of the buffer if their age becomes less-than or equal to the supplied age in
milliseconds or the buffer reaches its
size limit.
When observers subscribe to a terminated
ReplaySubject, they observe the items that remained in
the buffer after the terminal notification, regardless of their age, but at most
size items.
If an observer subscribes while the
ReplaySubject is active, it will observe only those items
from within the buffer that have age less than the specified time and each subsequent item, even if the
buffer evicts items due to the time constraint in the mean time. In other words, once an observer
subscribes, it observes items without gaps in the sequence except for the outdated items at the beginning
of the sequence.
Note that terminal notifications (
onError and
onCompleted) trigger eviction as well. For
example, with a max age of 5, the first item is observed at T=0, then an
onCompleted notification
arrives at T=10. If an observer subscribes at T=11, it will find an empty
ReplaySubject with just
an
onCompleted notification.