https://kotlinlang.org logo
#arrow
Title
# arrow
a

Alejandro Serrano.Mena

11/13/2023, 9:45 AM
hi! I'm trying to add a few more words about how Arrow and Compose are a great duo to the official docs https://github.com/arrow-kt/arrow-website/pull/252 I would really love to hear your feedback, about this particular PR, but also any other places were Arrow could be a bit more visible in the front-end space thank you color
thank you color 2
c

CLOVIS

11/13/2023, 10:13 AM
It looks good! Here's a similar article I wrote on the same subject, that could help with inspiration (see the section "Reactive UIs"): https://opensavvy.gitlab.io/pedestal/api-docs/backbone/index.html For context, it's a library that adds global caching strategies based on
Flow
and
Either
, to ensure a single request is fired even if the same value is displayed multiple times
d

dave08

11/13/2023, 10:19 AM
Very nice! But I'd say it's not really to simplify compose, but rather the viewmodels... in the actual compose code itself, I didn't really like mixing in Arrow...
a

Alejandro Serrano.Mena

11/13/2023, 10:42 AM
@dave08 interesting... do you mind elaborating? I found that using things like
Either
in my viewModel eventually permeate into my UI functions
d

dave08

11/13/2023, 10:44 AM
I basically pass down pure state and bubble up all events to my view model, so I don't have any network calls in compose for example. Instead, I'd use Either in my view model's state machine to create the new ui state.
If I use any Arrow in compose, it's Option... since that helps me express no value in a clearer way than null would in certain cases.
I could see that Ui state could be some Either with error state in it, but in that case, I prefer using a sealed interface representing all possible states and their properties rather than passing an Either down, since I don't really need it's features for compose code. I might be missing something you didn't write in that article, but every example you wrote there, I would do in the view model, and not in compose code @Alejandro Serrano.Mena.
a

Alejandro Serrano.Mena

11/13/2023, 10:52 AM
oh, maybe I should be more explicit about this, I consider ViewModel part of the "compose code"
👍🏼 1