Skip to content

Commit

Permalink
Register only one instance of epic if there is an attempt to register…
Browse files Browse the repository at this point in the history
… it again from another plugin.
  • Loading branch information
alexander-fedorenko committed Aug 18, 2022
1 parent 22ee6d2 commit d606efe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion web/client/utils/StateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,16 @@ export const createStoreManager = (initialReducers, initialEpics) => {
// Adds a new epics set, mutable by the specified key
addEpics: (key, epicsList) => {
if (Object.keys(epicsList).length) {
const epicsToAdd = Object.keys(epicsList).reduce((prev, current) => {
if (!epics[current]) {
epics[current] = epicsList[current];
return ({...prev, [current]: epicsList[current]});
}
return prev;
}, {});
const normalizedName = normalizeName(key);
muteState[normalizedName] = new Subject();
const isolatedEpics = isolateEpics(epicsList, muteState[normalizedName].asObservable());
const isolatedEpics = isolateEpics(epicsToAdd, muteState[normalizedName].asObservable());
wrapEpics(isolatedEpics).forEach(epic => epic$.next(epic));
}
},
Expand Down

0 comments on commit d606efe

Please sign in to comment.