I am busy in a project where the architect said th...
# rx
i
I am busy in a project where the architect said that we have not to use
Boolean
as Flag in the viewModel, but
Observable<Boolean>
and so on for everything because he claims that imperative and functional paradigms should not be used togheter. So I am in a situation where if I want to control a simple true false, have to make a
PublishSubject
, start it with a value, and then bind it, while I think would be much more efficient to do a simple Boolean
viewModel.isSomethingTrue
. Kotlin is not AFAIK a reactive functional language as clojure for instance, so I guess under the hood everytime I use RXJAVA I am going to build a lot on top of an Observable pattern a Boolean anyway! * Is reasonable and more performance effective to combine RXJAVA with ’Imperative” as I think, or I should bind evey single thing and make my Activity classess much more verbose as the architect is saying? *
a
Does that boolean ever change? If so, I think exposing it as an observable makes sense. If it's like "View has loaded" or some shit that only ever happens once I think it's overkill. The benefits of exposing data as observables is that it represents data that actually changes. If you're in a scenario where you need to react to whatever that boolean represents changing then reactive programming ( I don't think it's fair to call RxJava functional programming per say) is helpful.
i
is a flag variable, that I set false at the beginning, and then inside an
RXClick( button_send).subscribe{
becomes true, so that I can use it into onBackPressed to say finish()
a
So basically you have some boolean that gets set and then you check that boolean in
onBackPressed
to see if you should do something or another?
i
yes exactly
a
Then I'd say having that boolean represented as a stream is overkill and does not serve a purpose.
i
because I need to go in the `onActivityResult `of the other activity of the previous activity so to refresh
thanks