mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-18 07:07:47 +00:00
Using anything non-serializable for action types is discouraged: https://redux.js.org/faq/actions#actions In fact, this is the Flow definition for dispatching actions: declare export type DispatchAPI<A> = (action: A) => A; declare export type Dispatch<A: { type: $Subtype<string> }> = DispatchAPI<A>; Note how the `type` field is defined as a subtype of string, which Symbol isn’t.
28 lines
691 B
JavaScript
28 lines
691 B
JavaScript
// @flow
|
|
|
|
import { MiddlewareRegistry } from '../../base/redux';
|
|
|
|
import { sendEvent } from '../external-api';
|
|
|
|
import { INCOMING_CALL_ANSWERED, INCOMING_CALL_DECLINED } from './actionTypes';
|
|
|
|
/**
|
|
* Middleware that captures redux actions and uses the ExternalAPI module to
|
|
* turn them into native events so the app knows about them.
|
|
*
|
|
* @param {Store} store - The redux store.
|
|
* @returns {Function}
|
|
*/
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
const result = next(action);
|
|
|
|
switch (action.type) {
|
|
case INCOMING_CALL_ANSWERED:
|
|
case INCOMING_CALL_DECLINED:
|
|
sendEvent(store, action.type, /* data */ {});
|
|
break;
|
|
}
|
|
|
|
return result;
|
|
});
|