I'm develop an android app that communicates with the server using a protocol WebSocket. I use AsyncAndroid lib. WebSocket has listener, that receive data from server.
Something like this
private WebSocket.StringCallback mStringCallback = new WebSocket.StringCallback() {
        @Override
        public void onStringAvailable(String s) {
        }
    };
I need write api this, and i want use rxjava. But i cannot imagine, that should be Observable, and that Observer. i tried to do Observable string received from server into WebSocket listener, but i think it is bad idea. Are there any ideas how correctly build api. Thank u.
                        
You could wrap
WebSocketinto a new interface like this:Then in a
RxWebSocketimplementation you can usePublishSubjectwith an internalWebSocket.StringCallbackto publish the Strings.