Creates a time-bounded replay subject.
In this setting, the
ReplaySubject internally tags each observed item with a timestamp value
supplied by the
Scheduler and keeps only those whose age is less than the supplied time value
converted to milliseconds. For example, an item arrives at T=0 and the max age is set to 5; at T>=5
this first item is then evicted by any subsequent item or termination event, leaving the buffer empty.
Once the subject is terminated, observers subscribing to it will receive items that remained in the
buffer after the terminal event, regardless of their age.
If an observer subscribes while the
ReplaySubject is active, it will observe only those items
from within the buffer that have an age less than the specified time, and each item observed thereafter,
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 any 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.