https://kotlinlang.org logo
#coroutines
Title
# coroutines
d

dekans

12/12/2019, 8:14 AM
Is there a naming convention for functions returning a
Flow
? (like Async suffix for the ones returning a
Deferred
)
o

octylFractal

12/12/2019, 8:16 AM
for me the answer is no, because it is similar to a Stream-returning function, which I don't name differently from other functions. Typically they are named to indicate a collection/iterable, such as
listItems()
1
e

elizarov

12/12/2019, 8:21 AM
Deferred
is error-prone (it’s hot and you must not forget to await!) hence the naming convention to warn the user. There are no such problems with flow, hence no need for a special naming.
d

dekans

12/12/2019, 8:31 AM
Okay, thank you! :)
r

Ruckus

12/12/2019, 2:36 PM
you must not forget to await!
@elizarov Will you have issues if you don't await, or will you just not get the value?
e

elizarov

12/12/2019, 2:37 PM
You will lose exception if the method returning deferred failed, unless it was using structured concurrency.
r

Ruckus

12/12/2019, 2:38 PM
Ah, I didn't think about that. Thanks!
l

louiscad

12/12/2019, 9:41 PM
Somtimes, I suffix the property or function with
Flow
, like
locationUpdatesFlow
.
d

dekans

12/12/2019, 10:24 PM
That's what I was doing, but it's ugly!
r

Ruckus

12/12/2019, 10:59 PM
Maybe suffix with
AF
for, uh, as flow... 🧌
d

dekans

12/13/2019, 1:28 AM
I'm considering -Flower
😆 1
🙂
11 Views