Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize using top-level await #1

Open
evelynhathaway opened this issue Feb 27, 2019 · 1 comment
Open

Initialize using top-level await #1

evelynhathaway opened this issue Feb 27, 2019 · 1 comment
Labels
enhancement New feature or request idea Possible new features

Comments

@evelynhathaway
Copy link
Member

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

import pluginWebMidi, {init} from "./index";

await init(); // will use default options

export default pluginWebMidi;
export * from "./index";

comsumer.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
@evelynhathaway evelynhathaway added enhancement New feature or request idea Possible new features labels Feb 27, 2019
@evelynhathaway
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request idea Possible new features
Projects
None yet
Development

No branches or pull requests

1 participant