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.js 690B

1234567891011121314151617181920212223242526
  1. // @flow
  2. import { MiddlewareRegistry } from '../../base/redux';
  3. import { sendEvent } from '../external-api';
  4. import { INCOMING_CALL_ANSWERED, INCOMING_CALL_DECLINED } from './actionTypes';
  5. /**
  6. * Middleware that captures redux actions and uses the ExternalAPI module to
  7. * turn them into native events so the app knows about them.
  8. *
  9. * @param {Store} store - The redux store.
  10. * @returns {Function}
  11. */
  12. MiddlewareRegistry.register(store => next => action => {
  13. const result = next(action);
  14. switch (action.type) {
  15. case INCOMING_CALL_ANSWERED:
  16. case INCOMING_CALL_DECLINED:
  17. sendEvent(store, action.type, /* data */ {});
  18. break;
  19. }
  20. return result;
  21. });