Removed duplicated code when binding to mercure by checking if enabled first

This commit is contained in:
Alejandro Celaya
2020-06-06 09:24:05 +02:00
parent 05e3e87653
commit c46d5187c1
15 changed files with 47 additions and 53 deletions

View File

@@ -1,10 +1,9 @@
import { EventSourcePolyfill as EventSource } from 'event-source-polyfill';
export const bindToMercureTopic = (mercureInfo, realTimeUpdates, topic, onMessage, onTokenExpired) => () => {
const { enabled } = realTimeUpdates;
export const bindToMercureTopic = (mercureInfo, topic, onMessage, onTokenExpired) => () => {
const { mercureHubUrl, token, loading, error } = mercureInfo;
if (!enabled || loading || error) {
if (loading || error) {
return undefined;
}