Compose's very first recomposition runs synchronously. If you are using `launchMolecule` by the time...
j
Compose's very first recomposition runs synchronously. If you are using
launchMolecule
by the time you get the
StateFlow
returned a single recomposition has run. If you are using
moleculeFlow
then it will emit immediately, although i'm not sure if that involves posting to the dispatcher or not.
👍🏻 1
👍 1
a
Nothing looks too terribly incorrect here then…. It’s probably an id10t error somewhere 🥴
The events after init sometimes seem to be ignored, is the problem I’m facing
j
Hmm I don't know a lot about the behavior of
MutableSharedFlow
without any args. I've never used one.
Based on https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-shared-flow.html it looks like it defaults to rendezvous behavior which means two events sent between recompositions would be impossible
i would consider beefing up the extraBufferCapacity to a reasonable number like 64 and then using trySend at the callsite and checking that it was successful or otherwise crashing
realistically you should never have 64 events between frames (since you're using a context clock I'm assuming you're tied to frames)
a
Yeah, it seems that MutableSharedFlow has some other different behavior in that sense. The only reason I was using it was to mitigate the equality checks that occur when emitting to a state flow
I’m seeing some log events that weren’t running initially
j
yeah you definitely shouldn't use a state flow. a channel would be my other suggestion
a
Haven’t worked with channels much yet, I’ll give it a try 🙂
Oh my dumb fuck self
I forgot to emit the result of the network request, I was pulling my hair over this lol 🥴
Thank you for being my rubber duck rubber duck
I'm back in business 😎😎😎
c
unrelated: i really want to use molecule. i still dont get it. waiting for it to click. i did watch jakes droidcon talk on it, but if anyone has any pointers or any like tldr that made it click for you. pass it on. 😅
a
Realistically, you can think of it as another way to process incoming state. It doesn't have to be a presenter like how it's demoed, or used here, but it let's you transform data in a declarative way that's enabled by compose
Or, just to return state based off of the observed result of a side effect
@Colton Idle I reference the presenter in my ViewModel, for example. I go from Repository to Presenter which transforms data into a UI friendly state.
Compose is great at being a state container