mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
Add error logger service
This commit is contained in:
committed by
David Lechner
parent
6e4b22f841
commit
ec05ad38aa
@@ -0,0 +1,16 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2020 The Pybricks Authors
|
||||
|
||||
import { Action } from '../actions';
|
||||
import { BootloaderConnectionActionType } from '../actions/bootloader';
|
||||
import { combineServices } from '.';
|
||||
|
||||
async function consoleLog(action: Action): Promise<void> {
|
||||
switch (action.type) {
|
||||
case BootloaderConnectionActionType.DidError:
|
||||
console.error(action.err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
export default combineServices(consoleLog);
|
||||
@@ -6,6 +6,7 @@ import { Action, Dispatch } from '../actions';
|
||||
import { RootState } from '../reducers';
|
||||
import bootloader from './bootloader';
|
||||
import editor from './editor';
|
||||
import errorLog from './error-log';
|
||||
|
||||
type Service = (action: Action, dispatch: Dispatch, state: RootState) => Promise<void>;
|
||||
|
||||
@@ -27,7 +28,7 @@ export function combineServices(...services: Service[]): Service {
|
||||
};
|
||||
}
|
||||
|
||||
const rootService = combineServices(bootloader, editor);
|
||||
const rootService = combineServices(bootloader, editor, errorLog);
|
||||
|
||||
const serviceMiddleware: Middleware = (store) => (next) => (action): unknown => {
|
||||
runService(rootService, action, store.dispatch, store.getState());
|
||||
|
||||
Reference in New Issue
Block a user