Redux Saga: How to call yield + put within a nested function?
up vote
2
down vote
favorite
I am using WebRTC with redux sagas. One requirement is that I have to define peerConnection.onicecandidate
:
function* createPeerConnection(action) {
...
peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = (event) => {
if (event.candidate) {
yield put({ type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate });
}
}
}
However, yield put
is not working in this method. How would I change this so that it works with sagas?
redux redux-saga
add a comment |
up vote
2
down vote
favorite
I am using WebRTC with redux sagas. One requirement is that I have to define peerConnection.onicecandidate
:
function* createPeerConnection(action) {
...
peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = (event) => {
if (event.candidate) {
yield put({ type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate });
}
}
}
However, yield put
is not working in this method. How would I change this so that it works with sagas?
redux redux-saga
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am using WebRTC with redux sagas. One requirement is that I have to define peerConnection.onicecandidate
:
function* createPeerConnection(action) {
...
peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = (event) => {
if (event.candidate) {
yield put({ type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate });
}
}
}
However, yield put
is not working in this method. How would I change this so that it works with sagas?
redux redux-saga
I am using WebRTC with redux sagas. One requirement is that I have to define peerConnection.onicecandidate
:
function* createPeerConnection(action) {
...
peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = (event) => {
if (event.candidate) {
yield put({ type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate });
}
}
}
However, yield put
is not working in this method. How would I change this so that it works with sagas?
redux redux-saga
redux redux-saga
asked Feb 27 '17 at 10:42
Edmund
10.4k33103206
10.4k33103206
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Hope that the event channel can help you:
import { eventChannel, END } from 'redux-saga';
import { put, take } from 'redux-saga/effects';
import { videoSessionActions } from '../???/constants';
const rtcChannel = servers => eventChannel(emitter => {
const peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = event => {
if (event.candidate) {
emitter({type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate});
}
};
return () => {
peerConnection.close();
};
}
// ,buffers.expanding(1024) ???
);
function* createPeerConnection(servers) {
const ch = rtcChannel(servers);
while(true) { // eslint-disable-line no-constant-condition
const candidate = yield take(ch);
yield put(candidate);
}
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Hope that the event channel can help you:
import { eventChannel, END } from 'redux-saga';
import { put, take } from 'redux-saga/effects';
import { videoSessionActions } from '../???/constants';
const rtcChannel = servers => eventChannel(emitter => {
const peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = event => {
if (event.candidate) {
emitter({type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate});
}
};
return () => {
peerConnection.close();
};
}
// ,buffers.expanding(1024) ???
);
function* createPeerConnection(servers) {
const ch = rtcChannel(servers);
while(true) { // eslint-disable-line no-constant-condition
const candidate = yield take(ch);
yield put(candidate);
}
}
add a comment |
up vote
1
down vote
Hope that the event channel can help you:
import { eventChannel, END } from 'redux-saga';
import { put, take } from 'redux-saga/effects';
import { videoSessionActions } from '../???/constants';
const rtcChannel = servers => eventChannel(emitter => {
const peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = event => {
if (event.candidate) {
emitter({type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate});
}
};
return () => {
peerConnection.close();
};
}
// ,buffers.expanding(1024) ???
);
function* createPeerConnection(servers) {
const ch = rtcChannel(servers);
while(true) { // eslint-disable-line no-constant-condition
const candidate = yield take(ch);
yield put(candidate);
}
}
add a comment |
up vote
1
down vote
up vote
1
down vote
Hope that the event channel can help you:
import { eventChannel, END } from 'redux-saga';
import { put, take } from 'redux-saga/effects';
import { videoSessionActions } from '../???/constants';
const rtcChannel = servers => eventChannel(emitter => {
const peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = event => {
if (event.candidate) {
emitter({type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate});
}
};
return () => {
peerConnection.close();
};
}
// ,buffers.expanding(1024) ???
);
function* createPeerConnection(servers) {
const ch = rtcChannel(servers);
while(true) { // eslint-disable-line no-constant-condition
const candidate = yield take(ch);
yield put(candidate);
}
}
Hope that the event channel can help you:
import { eventChannel, END } from 'redux-saga';
import { put, take } from 'redux-saga/effects';
import { videoSessionActions } from '../???/constants';
const rtcChannel = servers => eventChannel(emitter => {
const peerConnection = new RTCPeerConnection(servers);
peerConnection.onicecandidate = event => {
if (event.candidate) {
emitter({type: videoSessionActions.SEND_LOCAL_CANDIDATE, payload: event.candidate});
}
};
return () => {
peerConnection.close();
};
}
// ,buffers.expanding(1024) ???
);
function* createPeerConnection(servers) {
const ch = rtcChannel(servers);
while(true) { // eslint-disable-line no-constant-condition
const candidate = yield take(ch);
yield put(candidate);
}
}
answered Mar 12 '17 at 21:52
DraganS
1,1361327
1,1361327
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42483669%2fredux-saga-how-to-call-yield-put-within-a-nested-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown