Ajout domaine 'init' dans les sagas

This commit is contained in:
wpetit 2020-02-25 14:35:47 +01:00
parent dbff21db9d
commit 60267305cb
4 changed files with 23 additions and 2 deletions

View File

@ -0,0 +1,8 @@
import { all } from 'redux-saga/effects';
import { checkSessionSaga } from './session.saga';
export function* rootSaga() {
yield all([
checkSessionSaga(),
]);
}

View File

@ -0,0 +1,11 @@
import { APIClient } from '../../services/api-client.service';
import { call } from 'redux-saga/effects';
export function* checkSessionSaga() {
const client = new APIClient();
try {
yield call(client.retrieveSessionUser);
} catch(err) {
console.error(err);
}
}

View File

@ -1,9 +1,11 @@
import { all } from 'redux-saga/effects';
import { rootSaga as authRootSaga } from './auth/root.saga';
import { rootSaga as failureRootSaga } from './failure/root.saga';
import { rootSaga as initRootSaga } from './init/root.saga';
export default function* rootSaga() {
yield all([
initRootSaga(),
authRootSaga(),
failureRootSaga(),
]);

View File

@ -7,7 +7,7 @@ export class APIClient {
this.baseURL = baseURL;
this.login = this.login.bind(this);
this.logout = this.logout.bind(this);
this.me = this.me.bind(this);
this.retrieveSessionUser = this.retrieveSessionUser.bind(this);
this.listUsers = this.listUsers.bind(this);
this.listRequests = this.listRequests.bind(this);
}
@ -20,7 +20,7 @@ export class APIClient {
return this._callAPI('/logout')
}
me() {
retrieveSessionUser() {
return this._callAPI('/me')
}