mirror of
https://github.com/wassname/talk.git
synced 2026-07-14 11:18:50 +08:00
15 lines
452 B
JavaScript
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});
|
|
};
|
|
}
|