Files
talk/client/coral-framework/services/events.js
T
2017-07-25 23:26:23 +07:00

15 lines
452 B
JavaScript

export function createReduxEmitter(eventEmitter) {
return (action) => {
// Handle apollo actions.
if (action.type.startsWith('APOLLO_')) {
if (action.type === 'APOLLO_SUBSCRIPTION_RESULT') {
const {operationName, variables, result: {data}} = action;
eventEmitter.emit(`subscription.${operationName}.data`, {variables, data});
}
return;
}
eventEmitter.emit(`action.${action.type}`, {action});
};
}