選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

reducer.ts 974B

1234567891011121314151617181920212223242526272829303132333435
  1. import ReducerRegistry from '../redux/ReducerRegistry';
  2. import { equals } from '../redux/functions';
  3. import { SET_JWT } from './actionTypes';
  4. export interface IJwtState {
  5. jwt?: string;
  6. }
  7. /**
  8. * Reduces redux actions which affect the JSON Web Token (JWT) stored in the
  9. * redux store.
  10. *
  11. * @param {Object} state - The current redux state.
  12. * @param {Object} action - The redux action to reduce.
  13. * @returns {Object} The next redux state which is the result of reducing the
  14. * specified {@code action}.
  15. */
  16. ReducerRegistry.register(
  17. 'features/base/jwt',
  18. (state: IJwtState = {}, action) => {
  19. switch (action.type) {
  20. case SET_JWT: {
  21. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  22. const { type, ...payload } = action;
  23. const nextState = {
  24. ...payload
  25. };
  26. return equals(state, nextState) ? state : nextState;
  27. }
  28. }
  29. return state;
  30. });