Ribs: [iOS] Explanation for RxSwift stream objects using an API Service

Created on 11 Dec 2017  路  4Comments  路  Source: uber/RIBs

Hello, is it possible to have an example ( or explanation) on how to use RxSwift to handle an http response that will modify the state of the app. It is said that "a handler is pointing to the corresponding stream class". Is it possible to have more details ? Since I didn't succeed to call a rib interactor from the service layer.

Thanks a lot

question

Most helpful comment

Same question in Android !

How to ensure the link between state-modifying responses from a Service layer and shared (Immutable)DataStreams ? :)

All 4 comments

In other words, an example of this explanation would be great :

"Not all state can be stored by the addition/removal of RIBs. For example, when a user鈥檚 profile settings change no RIB is attached or detached. Typically, we store this state inside streams of immutable models that re-emit when details change. For example, the user鈥檚 name may be stored in a ProfileDataStream that lives inside the LoggedIn scope. Only network responses have write access to this stream. We pass an interface that provides read access to these streams down the DI graph."

Same question in Android !

How to ensure the link between state-modifying responses from a Service layer and shared (Immutable)DataStreams ? :)

The way I do it is like so:

Service -> Interactor -> DataStream -> subscribed Presenter(s)

So the interactor invokes a function on the service layer to fetch, when the response comes back, it's fed into the data stream ( of which the interactor also has, the mutable one) and then the response is consumed by any subscribers of the stream ( the immutable one), usually presenters

In a way, I treat the datastreams as small individual state stores

Closing out stale issues.

Was this page helpful?
0 / 5 - 0 ratings