mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
Add common top-level Action type
This makes for better type inference.
This commit is contained in:
committed by
David Lechner
parent
6713afe198
commit
6e4b22f841
@@ -1,10 +1,10 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2020 The Pybricks Authors
|
||||
|
||||
import { Action, Dispatch } from 'redux';
|
||||
import { Action, Dispatch } from '../actions';
|
||||
|
||||
import {
|
||||
BootloaderConnectionActionType,
|
||||
BootloaderConnectionSendAction,
|
||||
didCancel,
|
||||
didConnect,
|
||||
didDisconnect,
|
||||
@@ -130,11 +130,10 @@ async function send(action: Action, dispatch: Dispatch): Promise<void> {
|
||||
if (!char) {
|
||||
throw Error('Not connected');
|
||||
}
|
||||
const sendAction = action as BootloaderConnectionSendAction;
|
||||
if (sendAction.withResponse) {
|
||||
await char.xWriteValueWithResponse(sendAction.data);
|
||||
if (action.withResponse) {
|
||||
await char.xWriteValueWithResponse(action.data);
|
||||
} else {
|
||||
await char.xWriteValueWithoutResponse(sendAction.data);
|
||||
await char.xWriteValueWithoutResponse(action.data);
|
||||
}
|
||||
dispatch(didSend());
|
||||
} catch (err) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright (c) 2020 The Pybricks Authors
|
||||
|
||||
import * as FileSaver from 'file-saver';
|
||||
import { Action, Dispatch } from 'redux';
|
||||
import { Action, Dispatch } from '../actions';
|
||||
import { EditorActionType, EditorOpenAction } from '../actions/editor';
|
||||
import { RootState } from '../reducers';
|
||||
import { combineServices } from '.';
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2020 The Pybricks Authors
|
||||
|
||||
import { Action, Dispatch, Middleware } from 'redux';
|
||||
import { Middleware } from 'redux';
|
||||
import { Action, Dispatch } from '../actions';
|
||||
import { RootState } from '../reducers';
|
||||
import bootloader from './bootloader';
|
||||
import editor from './editor';
|
||||
|
||||
Reference in New Issue
Block a user