https://kotlinlang.org logo
#rx
Title
# rx
l

locke

04/29/2019, 4:39 AM
Is there a better way to store an observable result for replay than replay subject? I have a stream that I want to create and execute the first time it's called, and then afterwards subscribing to that observable would just return the items that were originally emitted during the first call, rather than redo all of the processing. Describing this sure sounds like describing the lazy pattern (do work once, return repeatedly) but Googling the idea just gives you lazy stream generation, not results.
g

gsala

04/29/2019, 5:35 AM
Maybe
.cache()
and its overloads do what you want?
a

alexsullivan114

04/29/2019, 1:29 PM
yeah
cache
or
share
is probably what you're looking for.
u

ursus

04/29/2019, 4:12 PM
well... replay(1) ? thats exactly whats it for, but you need to subscribe to the same instance
j

Jeremy

04/29/2019, 7:22 PM
share+replay