* Computes the next entry in the log by applying an action.
( reducer: ActionReducer<any, any>, action: Action, state: any, error: any, errorHandler: ErrorHandler )
| 53 | * Computes the next entry in the log by applying an action. |
| 54 | */ |
| 55 | function computeNextEntry( |
| 56 | reducer: ActionReducer<any, any>, |
| 57 | action: Action, |
| 58 | state: any, |
| 59 | error: any, |
| 60 | errorHandler: ErrorHandler |
| 61 | ) { |
| 62 | if (error) { |
| 63 | return { |
| 64 | state, |
| 65 | error: 'Interrupted by an error up the chain', |
| 66 | }; |
| 67 | } |
| 68 | |
| 69 | let nextState = state; |
| 70 | let nextError; |
| 71 | try { |
| 72 | nextState = reducer(state, action); |
| 73 | } catch (err: any) { |
| 74 | nextError = err.toString(); |
| 75 | errorHandler.handleError(err); |
| 76 | } |
| 77 | |
| 78 | return { |
| 79 | state: nextState, |
| 80 | error: nextError, |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Runs the reducer on invalidated actions to get a fresh computation log. |
no test coverage detected