pakoito
04/01/2020, 7:07 PMJakub Pi
04/01/2020, 8:32 PMpakoito
04/01/2020, 9:08 PMIO
is not an architectural primitive, it’s a way of running suspend
functions with concurrency, parallelism, cancellation etcpakoito
04/01/2020, 9:08 PMpakoito
04/01/2020, 9:08 PMpakoito
04/01/2020, 9:09 PMJakub Pi
04/01/2020, 9:50 PMsuspend
, call load() eagerly and return Either<Throwable,ArchiveHashCache>
not wrapped in IO.
2. Return Flow<ArchiveHashCache>
from invoke() but this has the disadvantage of allowing the client to construct multiple times via collect() and also doesn't really fit the intent. Flow would be a better fit for a subscription on cache events (new elements, deletions)
Not for this portion specifically, but my App is intended to eventually run multiplatform, so I'm wary about having Arrow show up in the signature of my classes (this also applies to Either but that one is trivially replaceable)pakoito
04/01/2020, 9:59 PMReturncan’t you just write a custom constructor for flows that loads the cached value on every subsequent subscription?from invoke() but this has the disadvantage of allowing the client to construct multiple times via collect()Flow<ArchiveHashCache>
pakoito
04/01/2020, 9:59 PMLazy
with an additional side-effectpakoito
04/01/2020, 10:00 PMinvoke() function asso that’s the joke…suspend functions are always lazy because they won’t execute without an eager call kickstarting the whole chain, call load() eagerlysuspend
pakoito
04/01/2020, 10:01 PMlaunch
in kx.coroutines) is just a detail for the caller