are there any differences if in a Singleton class we expose a
Flow
from a public
val
than from a function that returns the
Flow
?
Are there any other cases where the
val
is preferred over the function?
j
Javier
01/12/2023, 8:34 PM
functions create a new instance, variable not (except if they use
get
)
f
franztesca
01/12/2023, 10:46 PM
I'd say that if the flow is cold and pure, the function fits best. If the flow consumes/uses and underlying resource or it's hot, then a property is fine.
For example, a s stateflow is always a property, while Sequence.asFlow is a function.