Files
pybricks-code/src/sagas.ts
T
dependabot[bot]andDavid Lechner a50cc9801c build(deps-dev): bump eslint-plugin-import from 2.26.0 to 2.27.2 (#1435)
* build(deps-dev): bump eslint-plugin-import from 2.26.0 to 2.27.2

Bumps [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) from 2.26.0 to 2.27.2.
- [Release notes](https://github.com/import-js/eslint-plugin-import/releases)
- [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-plugin-import/compare/v2.26.0...v2.27.2)

---
updated-dependencies:
- dependency-name: eslint-plugin-import
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix breaking changes in eslint sort order

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Lechner <david@pybricks.com>
2023-01-12 16:50:38 +00:00

68 lines
2.0 KiB
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (c) 2020-2022 The Pybricks Authors
import { eventChannel } from 'redux-saga';
import { all, spawn, take } from 'typed-redux-saga/macro';
import alerts, { AlertsSagaContext } from './alerts/sagas';
import app from './app/sagas';
import ble from './ble/sagas';
import blePybricksService from './ble-pybricks-service/sagas';
import errorLog from './error-log/sagas';
import explorer from './explorer/sagas';
import fileStorage, { FileStorageSageContext } from './fileStorage/sagas';
import flashFirmware from './firmware/sagas';
import hub from './hub/sagas';
import lwp3BootloaderProtocol from './lwp3-bootloader/sagas';
import lwp3BootloaderBle from './lwp3-bootloader/sagas-ble';
import mpy from './mpy/sagas';
import notifications from './notifications/sagas';
import type { TerminalSagaContext } from './terminal/sagas';
/**
* Listens to the 'pb-lazy-saga' event to spawn sagas from a React.lazy() initializer.
*/
function* lazySagas(): Generator {
const chan = eventChannel<CustomEvent<{ saga: () => void }>>((emit) => {
window.addEventListener('pb-lazy-saga', emit as EventListener);
return () => window.removeEventListener('pb-lazy-saga', emit as EventListener);
});
try {
for (;;) {
const event = yield* take(chan);
yield* spawn(event.detail.saga);
}
} finally {
chan.close();
}
}
/* istanbul ignore next */
export default function* (): Generator {
yield* all([
alerts(),
app(),
blePybricksService(),
ble(),
fileStorage(),
lwp3BootloaderBle(),
lwp3BootloaderProtocol(),
errorLog(),
explorer(),
flashFirmware(),
hub(),
mpy(),
notifications(),
lazySagas(),
]);
}
/**
* Combined type for all saga contexts.
*/
export type RootSagaContext = {
nextMessageId: () => number;
} & AlertsSagaContext &
FileStorageSageContext &
TerminalSagaContext;