redux-saga/effects#apply TypeScript Examples
The following examples show how to use
redux-saga/effects#apply.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
function* doSetUsername({ payload }: PayloadAction<string>) {
const manager: Manager = yield getContext('manager');
const username = payload;
try {
yield apply(manager, manager.setUsername, [username]);
yield put({ type: 'MANAGER_UPDATED' });
} catch (err) {
yield put({ type: 'MANAGER_ERROR', payload: err });
}
}
Example #2
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
function* doSendChatMessage({ payload }: PayloadAction<string>) {
const manager: Manager = yield getContext('manager');
const message = payload;
const from = manager.username;
try {
yield apply(manager.signaler, manager.signaler.text, [message, from]);
yield put({ type: 'MANAGER_UPDATED' });
} catch (err) {
yield put({ type: 'MANAGER_ERROR', payload: err });
}
}
Example #3
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
function* doSetLocalAudio({ payload }: PayloadAction<MediaStreamTrack | null>) {
const manager: Manager = yield getContext('manager');
const track = payload;
try {
if (track) {
yield apply(manager, manager.setTrack, ['audio', track]);
} else {
yield apply(manager, manager.stopTrack, ['audio']);
}
yield put({ type: 'MANAGER_UPDATED' });
} catch (err) {
yield put({ type: 'MANAGER_ERROR', payload: err });
}
}
Example #4
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
function* doSetLocalVideo({ payload }: PayloadAction<MediaStreamTrack | null>) {
const manager: Manager = yield getContext('manager');
const track = payload;
try {
if (track) {
yield apply(manager, manager.setTrack, ['video', track]);
} else {
yield apply(manager, manager.stopTrack, ['video']);
}
yield put({ type: 'MANAGER_UPDATED' });
} catch (err) {
yield put({ type: 'MANAGER_ERROR', payload: err });
}
}
Example #5
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
function* doSetResolution({ payload }: PayloadAction<number>) {
const resolution = payload;
try {
const localFeed: Feed = yield select((state) =>
state.feeds.find((feed: Feed) => feed.id === 'local')
);
if (localFeed.videoStream) {
const track = localFeed.videoStream.getVideoTracks()[0];
const constraints = {
height: { ideal: resolution },
width: { ideal: (resolution * 4) / 3 },
};
yield apply(track, track.applyConstraints, [constraints]);
}
yield put({ type: 'RESOLUTION_UPDATED' });
} catch (err) {
console.error(err);
yield put({ type: 'ERROR', payload: err });
}
}
Example #6
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
function* doDisableRemoteVideo({ payload }: PayloadAction<string>) {
const manager: Manager = yield getContext('manager');
const id = payload;
try {
const peer: MediaPeer = manager.mediaPeers.get(id) as MediaPeer;
yield apply(peer, peer.disableRemoteVideo, []);
yield put({ type: 'PEER_UPDATED' });
} catch (err) {
yield put({ type: 'PEER_ERROR', payload: err });
}
}
Example #7
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
function* doEnableRemoteVideo({ payload }: PayloadAction<string>) {
const manager: Manager = yield getContext('manager');
const id = payload;
try {
const peer: MediaPeer = manager.mediaPeers.get(id) as MediaPeer;
yield apply(peer, peer.enableRemoteVideo, []);
yield put({ type: 'PEER_UPDATED' });
} catch (err) {
yield put({ type: 'PEER_ERROR', payload: err });
}
}
Example #8
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
function* doSetIceServers() {
const manager: Manager = yield getContext('manager');
const iceServers: IceServer[] = yield select((state) => state.iceServers);
const servers = iceServers
.filter((server) => {
return server.enabled;
})
.map((server) => {
return {
urls: server.urls,
username: server.username,
credential: server.credential,
};
}) as IceServer[];
try {
yield apply(manager, manager.setIceServers, [servers]);
yield put({ type: 'MANAGER_UPDATED' });
} catch (err) {
console.log(err);
yield put({ type: 'MANAGER_ERROR', payload: err });
}
}