Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { eventChannel } from 'redux-saga';
- import { take, put } from 'redux-saga/effects';
- import { delay } from '../../common';
- import createAction from '../../actionCreator';
- import { createApolloClient } from '../../../components/apolloClient';
- import { CONNECTION_STATUS } from '../../../components/apolloClient/constants';
- export default function* gqlChannel(deviceId) {
- const channel = eventChannel(listener => {
- const apolloClient = createApolloClient(deviceId);
- const handleConnectionStatus = (data) => {
- listener(data);
- };
- apolloClient.emitter.on(CONNECTION_STATUS, handleConnectionStatus);
- // startListenToGraphQLMethods(apolloClient, deviceId, listener);
- // apolloClient.emitter.on('reconnect', startListenToGraphQLMethods(apolloClient, deviceId, listener));
- return () =>
- apolloClient.emitter.removeEventListener(CONNECTION_STATUS, handleConnectionStatus);
- });
- yield delay(2000);
- yield put(createAction(undefined, 'WIPE', { hovno: 1 }));
- while (true) {
- const action = yield take(channel);
- yield put(createAction(undefined, action.type, action.data, action.error));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement