Sharing is started when the first subscriber appears, immediately stops when the last subscriber disappears (by default), keeping the replay cache forever (by default).
It has the following optional parameters:
stopTimeout — configures a delay between the disappearance of the last subscriber and the stopping of the sharing coroutine. It defaults to zero (stop immediately).
replayExpiration — configures a delay between the stopping of the sharing coroutine and the resetting of the replay cache (which makes the cache empty for the shareIn operator and resets the cached value to the original
initialValuefor the stateIn operator). It defaults to Duration.INFINITE (keep replay cache forever, never reset buffer). Use Duration.ZERO value to expire the cache immediately.
This function throws IllegalArgumentException when either stopTimeout or replayExpiration are negative.