what is the proper way of sharing a flow ?
# coroutines
m
what is the proper way of sharing a flow ?
d
m
something like this:
Copy code
val flow = callbackFlow{
    offer(dispatchValue1())
    offer(dispatchValue2())
    offer(dispatchValue3())
    close()
}
collecting this flow multiple times will only call those functions once
d
So it will call the functions once, but will it return the same items again or will it just continue onto the next function that hasn't been called?
m
this was a silly example 😛 Let's say i have table in the database that i'm observing. then i collect that flow two times, i want them to 'share' results
as in, not being cold, and perform the work twice
d
Interesting. The link I sent you one part of what you're looking for.
I'll look for the other.
m
yes, i know 😛 but not ready yet. thanks for your help
p
Still looking for a alternative to replay(1).refcount()
👍 1