That's really not a managable way of handling rx. ...
# rx
p
That's really not a managable way of handling rx. That puts ton of state all over the place. Just call
executeRequest
a couple of times and you're into the fun 🙂
☝️ 1
u
@Paul Woitaschek, thanks. what would be the manageable way then?
p
Transform the stream without the side effect
Have one class which represents the state
For exmaple you have a selead class RequestState with an RequestState.Error(throwable), RequestState.Success(data), ...
Then use onErrorReturnItem(Error), startWith(Loading),...
u
@Paul Woitaschek, thanks. would you separate streams using, say, BehaviourRelay? Like in the example we’ve just discussed.
p
No, that's the point. That way you have everything scoped in one stream and no issues with mutliple subscribers etc.
u
How do you flatmap 2 observables returning those state objects? you have to add filters for Started events etc, makes code super messy imho
p
You don't, you only use it on consumer site
u
@Paul Woitaschek, have you got some cool examples at hand?
u
yea, but how do you know..it means those methods dont compose, you then have to extract methods which are the same but without the methods, public api is then murky, idk..