From cdea878e656d29317ff8cd53853cc7ff293d1bfa Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sat, 23 Jan 2021 18:35:44 -0600 Subject: [PATCH] convert editor sagas to typed-redux-saga/macro --- src/sagas/editor.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/sagas/editor.ts b/src/sagas/editor.ts index 8b80f5a8..7db2ec38 100644 --- a/src/sagas/editor.ts +++ b/src/sagas/editor.ts @@ -1,9 +1,8 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors -import { Ace } from 'ace-builds'; import FileSaver from 'file-saver'; -import { select, takeEvery } from 'redux-saga/effects'; +import { select, takeEvery } from 'typed-redux-saga/macro'; import { EditorActionType, EditorOpenAction, @@ -15,9 +14,7 @@ import { RootState } from '../reducers'; const decoder = new TextDecoder(); function* open(action: EditorOpenAction): Generator { - const editor = (yield select( - (s: RootState) => s.editor.current, - )) as Ace.EditSession | null; + const editor = yield* select((s: RootState) => s.editor.current); // istanbul ignore next: it is a bug to dispatch this action with no current editor if (editor === null) { @@ -30,9 +27,7 @@ function* open(action: EditorOpenAction): Generator { } function* saveAs(_action: EditorSaveAsAction): Generator { - const editor = (yield select( - (s: RootState) => s.editor.current, - )) as Ace.EditSession | null; + const editor = yield* select((s: RootState) => s.editor.current); // istanbul ignore next: it is a bug to dispatch this action with no current editor if (editor === null) { @@ -46,9 +41,7 @@ function* saveAs(_action: EditorSaveAsAction): Generator { } function* reloadProgram(_action: EditorReloadProgramAction): Generator { - const editor = (yield select( - (s: RootState) => s.editor.current, - )) as Ace.EditSession | null; + const editor = yield* select((s: RootState) => s.editor.current); // istanbul ignore next: it is a bug to dispatch this action with no current editor if (editor === null) { @@ -60,7 +53,7 @@ function* reloadProgram(_action: EditorReloadProgramAction): Generator { } export default function* (): Generator { - yield takeEvery(EditorActionType.Open, open); - yield takeEvery(EditorActionType.SaveAs, saveAs); - yield takeEvery(EditorActionType.ReloadProgram, reloadProgram); + yield* takeEvery(EditorActionType.Open, open); + yield* takeEvery(EditorActionType.SaveAs, saveAs); + yield* takeEvery(EditorActionType.ReloadProgram, reloadProgram); }