Ajout domaine 'init' dans les sagas
This commit is contained in:
parent
dbff21db9d
commit
60267305cb
8
frontend/src/sagas/init/root.saga.js
Normal file
8
frontend/src/sagas/init/root.saga.js
Normal file
@ -0,0 +1,8 @@
|
||||
import { all } from 'redux-saga/effects';
|
||||
import { checkSessionSaga } from './session.saga';
|
||||
|
||||
export function* rootSaga() {
|
||||
yield all([
|
||||
checkSessionSaga(),
|
||||
]);
|
||||
}
|
11
frontend/src/sagas/init/session.saga.js
Normal file
11
frontend/src/sagas/init/session.saga.js
Normal 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);
|
||||
}
|
||||
}
|
@ -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(),
|
||||
]);
|
||||
|
@ -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')
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user