View Model state preservation using autoConnect

1 · Instacart · March 8, 2019, 2:45 a.m.
An example of using rx autoConnect to avoid managing mutable state— the entire state is maintained within the stream.TL;DR.autoConnect() allows us to maintain a separate lifecycle for a stream and its subscribers. This lends itself nicely for preserving a View Model state independently from the Activity lifecycle. We start with examples of persisting the state outside of the stream, and end up using .autoConnect() to maintain the state within the stream. Not sure what autoConnect is? Here’s an e...