When we connect through the socket, a string will receive as ‘Message’ through a streamline. In many cases this string is a JSON.
In our sample the json can be mapped to ModelA or ModelB or neither.
By using ‘RxStarScream’ I created 2 Maybe<ModelA>
and Maybe<ModelB>
that update Labels whether the received JSON can be mapped to observeable’s type or not.
- Try connecting to socket server by clicking ‘Connect’.
- Emit modelA -> the labels are updated to modelA immediately.
- Emit modelB -> the labels are updated to modelB immediately.
don’t forget to hit ‘star’ button on github 😋😉🤟🏻