You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.native.js 741B

12345678910111213141516171819202122232425262728293031
  1. // @flow
  2. import { MiddlewareRegistry } from '../../base/redux';
  3. import { CLIENT_RESIZED } from './actionTypes';
  4. import { setAspectRatio, setReducedUI } from './actions';
  5. /**
  6. * Middleware that handles widnow dimension changes and updates the aspect ratio and
  7. * reduced UI modes accordingly.
  8. *
  9. * @param {Store} store - The redux store.
  10. * @returns {Function}
  11. */
  12. MiddlewareRegistry.register(({ dispatch }) => next => action => {
  13. const result = next(action);
  14. switch (action.type) {
  15. case CLIENT_RESIZED: {
  16. const { clientWidth: width, clientHeight: height } = action;
  17. dispatch(setAspectRatio(width, height));
  18. dispatch(setReducedUI(width, height));
  19. break;
  20. }
  21. }
  22. return result;
  23. });