(name: T, fn: any)
| 527 | (name: 'reduceSessions', fn: ISessionReducer): ISessionReducer; |
| 528 | (name: 'reduceTermGroups', fn: ITermGroupReducer): ITermGroupReducer; |
| 529 | } = <T extends keyof typeof reducersDecorators>(name: T, fn: any) => { |
| 530 | const reducers = reducersDecorators[name]; |
| 531 | return (state: any, action: any) => { |
| 532 | // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 533 | let state_ = fn(state, action); |
| 534 | |
| 535 | reducers.forEach((pluginReducer: any) => { |
| 536 | let state__; |
| 537 | |
| 538 | try { |
| 539 | // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 540 | state__ = pluginReducer(state_, action); |
| 541 | } catch (err) { |
| 542 | notify('Plugin error', `${fn._pluginName}: Error occurred in \`${name}\`. Check Developer Tools for details.`, { |
| 543 | error: err |
| 544 | }); |
| 545 | return; |
| 546 | } |
| 547 | |
| 548 | if (!state__ || typeof state__ !== 'object') { |
| 549 | notify('Plugin error', `${fn._pluginName}: Invalid return value of \`${name}\`.`); |
| 550 | return; |
| 551 | } |
| 552 | |
| 553 | state_ = state__; |
| 554 | }); |
| 555 | |
| 556 | return state_; |
| 557 | }; |
| 558 | }; |
| 559 | |
| 560 | export function decorateTermGroupsReducer(fn: ITermGroupReducer) { |
| 561 | return decorateReducer('reduceTermGroups', fn); |
no test coverage detected