Make streaming API use one pattern-matching redis pubsub connection
Refresh timelines when streaming API reconnects in the UI
This commit is contained in:
parent
9d5fb49cd8
commit
02e91a96dd
3 changed files with 74 additions and 36 deletions
|
@ -10,12 +10,13 @@ const createWebSocketURL = (url) => {
|
|||
return a.href;
|
||||
};
|
||||
|
||||
export default function getStream(accessToken, stream, { connected, received, disconnected }) {
|
||||
export default function getStream(accessToken, stream, { connected, received, disconnected, reconnected }) {
|
||||
const ws = new WebSocketClient(`${createWebSocketURL(STREAMING_API_BASE_URL)}/api/v1/streaming/?access_token=${accessToken}&stream=${stream}`);
|
||||
|
||||
ws.onopen = connected;
|
||||
ws.onmessage = e => received(JSON.parse(e.data));
|
||||
ws.onclose = disconnected;
|
||||
ws.onopen = connected;
|
||||
ws.onmessage = e => received(JSON.parse(e.data));
|
||||
ws.onclose = disconnected;
|
||||
ws.onreconnect = reconnected;
|
||||
|
||||
return ws;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue