Flávio Caetano

February 25, 2016

Recently we had to integrate a chat-like comment feature to our new Winnin App
Our backend team decided to build it using websockets, so when it came to the
app implementation, my first thought was to search for an opensource swift framework
that did confirm to the Websocket Protocol.
We decided to go with Starscream since
it seemed simple and reliable enough.

In the first drafts of the new app, a decision was made to adopt reactive programming
in the app, more specifically RxSwift. Many sprints later, we’ve limited our
Rx use to cross-object events and network communications. Not surprisingly, we
wanted to use websockets reactively.

Using an enum as the element type allows us to have every interaction with the
websocket server in one property that is also easily filtered by message type. If
we need to know when the websocket connects, we can simply filter the stream: