cpunion/react-actioncable-provider

How to check there is a connection?

hcyildirim opened this issue · 1 comments

Hi,

I want to check if there is a connection. This is necessary for my app because users keep their apps on background and when app is in foreground I want to make sure there is a connection.

So how can I check there is a connection? How to keep app connected?

Thank you.

I've solved this by using ref. But I don't know this is a correct way to solve this problem. Hope it helps someone.

this.channelRef.cable.consumer.connection.disconnected // true for disconnected, false for connected

 <ActionCable
          ref={(c) => {
            this.channelRef = c;
          }}
  />