I think it would be good to have a submodule that uses top-level await to halt code execution until the user or user agent accepts the Web MIDI API permission. I think it would be a bad idea to do this on the main module since it could be blocked for minutes.
Possible example of a wrapper that could use top level await to simplify implementation
`@rocketry/plugin-web-midi/sync`
```js
import pluginWebMidi, {init} from "./index";
await init(); // will use default options
export default pluginWebMidi;
export * from "./index";
```
---
`comsumer.js`
```js
import "@rocketry/plugin-web-midi/sync";
import rocketry from "@rocketry/core";
// Use Rocketry here without having to worry about making an async context
// Nothing past the last import will run until the permissions have been accepted/rejected
```
I think it would be good to have a submodule that uses top-level
await
to halt code execution until the user or user agent accepts the Web MIDI API permission. I think it would be a bad idea to do this on the main module since it could be blocked for minutes.Currently, the proposal for top-level await is at stage 2 and I don't know when/if support will come to Node.js.
Possible example of a wrapper that could use top level await to simplify implementation
`@rocketry/plugin-web-midi/sync` ```js import pluginWebMidi, {init} from "./index"; await init(); // will use default options export default pluginWebMidi; export * from "./index"; ``` --- `comsumer.js` ```js import "@rocketry/plugin-web-midi/sync"; import rocketry from "@rocketry/core"; // Use Rocketry here without having to worry about making an async context // Nothing past the last import will run until the permissions have been accepted/rejected ```