Skip to content

Instantly share code, notes, and snippets.

@praveen001
Last active July 22, 2019 11:26
Show Gist options
  • Save praveen001/f13bdce32c1d09bbb1d5a5efa8deadc3 to your computer and use it in GitHub Desktop.
Save praveen001/f13bdce32c1d09bbb1d5a5efa8deadc3 to your computer and use it in GitHub Desktop.
Redux Observable WebSocket
const connectEpic = (action$, state$: StateObservable<IState>) =>
action$
.ofType(WebsocketActionTypes.CONNECT)
.switchMap((action: IConnectWebsocketAction) =>
connectSocket(state$.value.eventConfig.webSocketURL)
.map(data => receiveMessageFromWebSocket(data)) // <-- Map and fire receive action
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment