https://kotlinlang.org logo
#orbit-mvi
Title
# orbit-mvi
k

kikermo

05/03/2020, 11:10 AM
Hey @Mikolaj Leszczynski. We were talking about this previously, but I am using orbit with rx, and on the transformation, I pass the
eventObservable
and
currentState
to my transformers that I have defined outside (similar to the example). When I pass that
currentState
, I am passing its value on the cretion of the stream so it will always be the initial version of that state. In order to have the latest value of that state, the actual current state, what I did was looping back an object that had the things I needed from the state to make my request. That solves my problem, but I was thinking what other alternatives we have. One would be modifying the stream with a
map
but maybe there is a more obvious one I am missing. Thanks in advance.
m

Mikolaj Leszczynski

05/03/2020, 1:30 PM
So the
currentState
field will capture the latest state and like you rightly said, if you pass it to an external transformer this value is captured when the orbit container is instantiated. The easiest solution to this is to pass a lambda to your delegate class instead. I.e. not
transform { delegate.something(eventObservable, currentState) }
but
transform { delegate.something(eventObservable, { currentState }) }
. Then whenever you invoke that lambda in your observable you will have the current state.
k

kikermo

05/03/2020, 7:41 PM
I haven’t though about that one, thanks a lot.