Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle additional websocket connection state #38

Open
lwojciechowski opened this issue Jun 15, 2018 · 1 comment
Open

How to handle additional websocket connection state #38

lwojciechowski opened this issue Jun 15, 2018 · 1 comment

Comments

@lwojciechowski
Copy link

I made initial implementation of the websocket callbag. The problem I encountered is: how to tell the user that WebSocket is connected. So far I implemented buffer that stores the data that should be sent to the WebSocket connection, but I believe that information about successful connection is way too important to hide it inside callbag.

I checked WebsocketSubject from RxJs, and they allow to pass openedObervable in the config, that stores connection state.

@halcaponey
Copy link

halcaponey commented Jul 27, 2019

Either use Object.defineProperty like :

return Object.defineProperty((type, data) => {
       // ...
    },
    'closed',
    {
        get: () => !ws || ws.readyState !== 1,
});

Or define a second source who tells if the connection is closed or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants