Rocket.Chat.ReactNative/app/sagas/rooms.js

24 lines
639 B
JavaScript
Raw Normal View History

import { put, call, takeEvery } from 'redux-saga/effects';
2017-08-17 02:06:22 +00:00
import * as types from '../actions/actionsTypes';
import { roomsSuccess, roomsFailure } from '../actions/rooms';
import RocketChat from '../lib/rocketchat';
const getRooms = function* getRooms() {
return yield RocketChat.getRooms();
};
2017-08-17 02:06:22 +00:00
const watchRoomsRequest = function* watchRoomsRequest() {
try {
2017-08-21 00:11:46 +00:00
console.log('getRooms');
yield call(getRooms);
yield put(roomsSuccess());
} catch (err) {
console.log(err);
yield put(roomsFailure(err.status));
2017-08-17 02:06:22 +00:00
}
};
const root = function* root() {
yield takeEvery(types.LOGIN.SUCCESS, watchRoomsRequest);
};
export default root;