summaryrefslogtreecommitdiff
path: root/frontend/src/sagas/errors.js
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2017-07-24 23:51:43 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2017-07-24 23:52:40 +0200
commit324b51049acac27ea3e7f71acad47aa729dfd8db (patch)
tree198640ae8788e6275e061cf38cea621206160bbf /frontend/src/sagas/errors.js
parentUpgrade flow-bin (diff)
downloadseven-wonders-324b51049acac27ea3e7f71acad47aa729dfd8db.tar.gz
seven-wonders-324b51049acac27ea3e7f71acad47aa729dfd8db.tar.bz2
seven-wonders-324b51049acac27ea3e7f71acad47aa729dfd8db.zip
Improve sevenWondersApi and types
Diffstat (limited to 'frontend/src/sagas/errors.js')
-rw-r--r--frontend/src/sagas/errors.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/frontend/src/sagas/errors.js b/frontend/src/sagas/errors.js
index 86fa0124..eece98c8 100644
--- a/frontend/src/sagas/errors.js
+++ b/frontend/src/sagas/errors.js
@@ -1,10 +1,13 @@
-import {apply, cancelled, take} from 'redux-saga/effects';
-import {toastr} from 'react-redux-toastr';
-import {ApiError, SevenWondersSession} from '../api/sevenWondersApi';
-import type {Channel} from 'redux-saga';
+// @flow
+import { toastr } from 'react-redux-toastr'
+import type { Channel } from 'redux-saga'
+import { eventChannel } from 'redux-saga'
+import { apply, cancelled, take } from 'redux-saga/effects'
+import type { ApiError } from '../api/model'
+import type { SevenWondersSession } from '../api/sevenWondersApi'
-export default function* errorHandlingSaga(session: SevenWondersSession) {
- const errorChannel: Channel<ApiError> = yield apply(session, session.watchErrors, []);
+export default function* errorHandlingSaga(session: SevenWondersSession): * {
+ const errorChannel: Channel<ApiError> = yield eventChannel(session.watchErrors());
try {
while (true) {
const error: ApiError = yield take(errorChannel);
@@ -18,7 +21,7 @@ export default function* errorHandlingSaga(session: SevenWondersSession) {
}
}
-function* handleOneError(err: ApiError) {
+function* handleOneError(err: ApiError): * {
console.error('Error received on web socket channel', err);
const msg = buildMsg(err);
yield apply(toastr, toastr.error, [msg, { icon: 'error' }]);
bgstack15