These are chat archives for ReactiveX/RxJava

31st
Aug 2016
Dorus
@Dorus
Aug 31 2016 00:29
@gruns Oops right, Java doesn't really support anon classes that get passed around. Guess you have to lift a small data-object. That's unrelated to lambdas, those can run on Java android if you use retrolambda.
Behzodbek Qodirov
@behzodbek
Aug 31 2016 20:25

I have this class. I’d like client of this class get the instance of the field chatHub as soon as it assigned in the callback

connection.connected(() -> chatHub = connection.createHubProxy("ChatHub"));

chatHub might be null. We have to push chatHub through subscriber as soon as it has been initialized;
any ideas?

public class SignalRManager {
    private HubProxy chatHub;

    public SignalRManager() {
        Platform.loadPlatformComponent(new AndroidPlatformComponent());

        HubConnection connection = new HubConnection("https://test.chatlasapp.com/signalr/hubs");
        connection.stateChanged((connectionState, connectionState2) -> Log.i("SignalR", connectionState.name() + "->" + connectionState2.name()));
        connection.closed(() -> {
            Log.i("SignalR", "Closed");
            chatHub = null;
            connection.start();
        });
        connection.connected(() -> chatHub = connection.createHubProxy("ChatHub"));

        connection.start();
    }

    Observable<HubProxy> getHubProxy(){

    }
}