ReactiveX emit null or sentinel value after timeout

Viewed 1401

Looking for a clean way to transform a source Observable to emit a single null (or sentinel value) after not emitting an item for some duration.

For example, if the source observable emits 1, 2, 3 then stops emitting for 10 seconds before emitting 4, 5, 6 I would like the emitted items to be 1, 2, 3, null, 4, 5, 6.

The use case is for displaying values in a UI where the displayed value should turn into a dash - or N/A if the last emitted value is stale/old.

I looked into the timeout operator but it terminates the Observable when the timeout occurs which is undesirable.

Using RxJava.

2 Answers
Related